SplitterGadget events
Posted: Sun Jun 06, 2004 6:21 pm
When trying to catch splitter gadget events some disapoitments may occur ...
I finally found that the returned handle is not the one to use in the callback or in the main program, but a child of it.
There is a small code to show this.
I finally found that the returned handle is not the one to use in the callback or in the main program, but a child of it.
There is a small code to show this.
Code: Select all
Global hSplitterGadget.l
#Button1 = 0
#Button2 = 1
#Splitter = 2
Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select Message
Case #WM_MOUSEACTIVATE
If wParam = hSplitterGadget
Debug "Splitter touched"
EndIf
EndSelect
ProcedureReturn Result
EndProcedure
If OpenWindow(0, 0, 0, 230, 180, #PB_Window_SystemMenu|#PB_Window_ScreenCentered, "SplitterGadget")
If CreateGadgetList(WindowID(0))
hButtonGadget1 = ButtonGadget(#Button1,0, 0, 0, 0, "Button 1") ; No need to specify size or coordiantes
hButtonGadget2 = ButtonGadget(#Button2,0, 0, 0, 0, "Button 2") ; as they will be sized automatically
hSplitterGadget = SplitterGadget(#Splitter, 5, 5, 220, 120, #Button1, #Button2, #PB_Splitter_Separator)
hSplitterGadget = GetParent_(hSplitterGadget)
SetGadgetAttribute(#Splitter, #PB_Splitter_FirstMinimumSize, 20)
SetGadgetAttribute(#Splitter, #PB_Splitter_SecondMinimumSize, 20)
hTextGadget = TextGadget(3, 10, 135, 210, 40, "Above GUI part shows two automatically resizing buttons inside the 230x130 SplitterGadget area.",#PB_Text_Center )
SetWindowCallback(@MyWindowCallback())
Repeat
ev = WaitWindowEvent()
Select ev
Case #PB_Event_CloseWindow : quit =1
Case #PB_Event_Gadget
EventGadgetID = EventGadgetID()
Debug "Gadget# = " + Str(EventGadgetID) + " Gadget handle = " + Str(GadgetID(EventGadgetID))
EndSelect
Until quit=1
EndIf
EndIf
End