' createbutton.bmx
Strict
Local window:TGadget
Local button:TGadget[5]
Type myinfo
Field info1:String="boo"
End Type
window=CreateWindow("MaxGui Buttons",40,40,240,300,Null,WINDOW_TITLEBAR)
button[0]=CreateButton("Push Button",10,10,140,24,window,BUTTON_PUSH)
button[1]=CreateButton("Checkbox Button",10,34,140,24,window,BUTTON_CHECKBOX)
button[2]=CreateButton("Radio Button",10,58,140,24,window,BUTTON_RADIO)
button[3]=CreateButton("OK",10,82,70,24,window,BUTTON_OK)
button[4]=CreateButton("Cancel",84,82,70,24,window,BUTTON_CANCEL)
button[0].context="This is my additional information"
Local other_info:myinfo=New myinfo
other_info.info1="HAllo world"
button[1].context=other_info
While True
WaitEvent
Select EventID()
Case EVENT_WINDOWCLOSE
End
Case EVENT_GADGETACTION
If EventSource()=button[0]
Print "Context "+String(button[0].context)
End If
If EventSource()=button[1]
Local con:myinfo=myinfo(button[1].context)
Print "Context "+con.info1
End If
Print "EVENT_GADGETACTION"
End Select
Wend
Of course you need to specify (to cast) the object you want to store in the general context:object
|