PureGUI is dead, long live Connect.DLL 8O
Fred, you have done a good job with the Event Stuff in PureBasic that PureGUI is no longer needed.
I can have all special gadget events I need with PureBasic 3.7 - sweet!
( seems to work fine now - not all Gadgets tested though... )
The only thing remaining is the automatic calling of events for Gadgets.
(...and #PB_ANY for Memory, Directories and files etc.

I've put the remaining functions in a DLL with 3 Functions in it:
InitConnect(), Connect() and GetConnection().
My PureBasic code now looks like this: (example)
Code: Select all
OpenWindow(1,100,200,320,240,#PB_Window_SystemMenu | #PB_Window_SizeGadget,"Test")
CreateGadgetList(WindowID(1))
AdvancedGadgetEvents(#TRUE)
InitConnect()
CreateMenu(1,WindowID(1))
MenuTitle("File")
MenuItem(Connect(#PB_Event_Menu, ?MenuNew),"New")
MenuItem(Connect(#PB_Event_Menu, ?MenuOpen),"Open")
MenuItem(Connect(#PB_Event_Menu, ?MenuSave),"Save")
CreateToolBar(1,WindowID(1))
ToolBarStandardButton(Connect(#PB_Event_Menu, ?MenuNew),#PB_ToolBarIcon_New)
ToolBarStandardButton(Connect(#PB_Event_Menu, ?MenuOpen),#PB_ToolBarIcon_Open)
ToolBarStandardButton(Connect(#PB_Event_Menu, ?MenuSave),#PB_ToolBarIcon_Save)
ButtonGadget(Connect(#PB_Event_Gadget, ?Button1),10,30,100,25,"Button 1")
ButtonGadget(Connect(#PB_Event_Gadget, ?Button2),10,80,100,25,"Button 2")
ButtonGadget(Connect(#PB_Event_Gadget, ?Button3),10,130,100,25,"Button 3")
Repeat
Event.l = WaitWindowEvent()
Select Event
Case #PB_Event_Menu
CallFunctionFast(GetConnection(#PB_Event_Menu, EventMenuID()))
Case #PB_Event_Gadget
CallFunctionFast(GetConnection(#PB_Event_Gadget, EventGadgetID()))
EndSelect
Until Event = #PB_Event_CloseWindow
End
Something like this: (example - only menues are shown...)
Code: Select all
;- User Functions
MenuNew:
Debug "SubDir MenuNew"
Debug GetConnection(#PB_Event_Menu, ?MenuNew)
Return
MenuOpen:
Debug "SubDir MenuOpen"
Debug GetConnection(#PB_Event_Menu, ?MenuOpen)
DisableMenuItem(GetConnection(#PB_Event_Menu, ?MenuOpen),1)
Return
MenuSave:
Debug "SubDir MenuSave"
Debug GetConnection(#PB_Event_Menu, ?MenuSave)
If GetMenuItemState(1,GetConnection(#PB_Event_Menu, ?MenuSave)) = 1
SetMenuItemState(1,GetConnection(#PB_Event_Menu, ?MenuSave),0)
Else
SetMenuItemState(1,GetConnection(#PB_Event_Menu, ?MenuSave),1)
EndIf
Return
Connect(ChildType, EventFunctionSubroutine) = gives a number to a gadget and connects it to a sub routine.
GetConnection(ChildType, EventID) = returns the address of the EventFunctionSubroutine
or
GetConnection(ChildType, EventFunctionSubroutine) = returns the GadgetNumber connected to the EventFunctionSubroutine
Now GUI coding is a breeze - for lazy coders like me
