Code: Select all
Procedure SubClass(hwnd, msg, wparam, lparam)
oldproc = GetProp_(hwnd, "oldproc")
gadget2 = GetProp_(hwnd, "gadget2")
var1 = GetProp_(hwnd, "var1")
; Now all the vars are known and specific to this instance only
Select msg
Case ..
Case ..
Case #WM_DESTROY
RemoveProp_(hwnd, "oldproc")
RemoveProp_(hwnd, "var1")
RemoveProp_(hwnd, "gadget2")
EndSelect
EndProcedure
Procedure MyGadget(GadgetNumber, x, y, etc..)
gadget1 = StringGadget(GadgetNumber, ... etc)
gadget2 = CreateWindowEx_( arguments etc..)
var1 = animportantvalue
oldproc = SetWindowLong_( set up the subclass)
; associate all vars and handles with the instance
SetProp_(gadget1, "oldproc", oldproc)
SetProp_(gadget1, "gadget2", gadget2)
SetProp_(gadget1, "var1", var1)
ProcedureReturn GadgetNumber
EndProcedure
Code: Select all
*this = AllocateMemory(SizeOf(MyStruct))
; write your vars
SetWindowLong_(hwnd, #GWL_USERDATA, *this)
Code: Select all
*this.MyStruct = GetWindowLong_(hwnd, #GWL_USERDATA)
var1 = *this\var1
PureBasic in v4 leaves this field open for us to use for all gadgets except the WebGadget, see here:
http://www.purebasic.fr/english/viewtopic.php?t=23354