05-08-2005, 12:03 AM
I've got a wonderful system for handling objects in my program. It allows a new module to be created, and with only 15 or so lines of code, a new object, complete with events and their handlers, can be created.
However, the Object data type that holds the information for an object needs to be very efficient - I want no wasted space. So, I created a field within it: extentions as any pointer
Using this field, I want to be able to point to any data type, and reference fields of that data type in the code. For example:
And then I would like to do something like this:
However, this doesn't work. And I'm not sure how I would go about doing something like this.
v1c, any ideas?
However, the Object data type that holds the information for an object needs to be very efficient - I want no wasted space. So, I created a field within it: extentions as any pointer
Using this field, I want to be able to point to any data type, and reference fields of that data type in the code. For example:
Code:
type objectData
x as integer
y as integer
w as integer
h as integer
caption as string
handler as sub(ref as objectData pointer, message as messageTypes)
drawproc as sub(ref as objectData pointer)
extensions as any pointer
end type
type simpleExtension
fonthandle as bFont pointer
fontproperties as bFontProperties
backcolor as integer
forecolor as integer
end type
And then I would like to do something like this:
Code:
dim obj as objectData pointer
obj = createObject()
obj->extensions = callocate(len(simpleExtension))
obj->extensions->fonthandle = someFont
obj->extensions->backcolor = rgb(128, 255, 128)
However, this doesn't work. And I'm not sure how I would go about doing something like this.
v1c, any ideas?
color=blue]subxero - admin at this place.[/color]