Re: Should PureBasic become my main development system?
Posted: Thu Sep 22, 2022 3:33 pm
For me, the best IDE (even better that VB6) was the Delphi one 

http://www.purebasic.com
https://www.purebasic.fr/english/
It's been a while since I did anything involving PB gadgets (recently I've tended to make application servers with an HTML ui) but this skeleton shows how I liked to layout code for apps with multiple windows:radsoft wrote: Wed Sep 14, 2022 3:51 am I'm drawn to PureBasic by everything it offers and I think my main concern now is how I'll be able to develop an application with multiple windows in a timely way.
Code: Select all
Enumeration windows
#frmMain
#frmChild
EndEnumeration
Enumeration gadgets
#frmMain_btnChild
#frmChild_btnOK
EndEnumeration
; child window - definition and handlers could be in separate file(s)
Procedure frmChild_Open()
If OpenWindow(#frmChild, 0, 0, 200, 150, "child", #PB_Window_SystemMenu|#PB_Window_WindowCentered)
ButtonGadget(#frmChild_btnOK, 10, 10, 150, 30, "Show Message")
EndIf
EndProcedure
; child window's gadget handlers
Procedure frmChild_onGadget(nGadget, nEventType, nX, nY)
Select nGadget
Case #frmChild_btnOK
MessageRequester("", "Hello, World!", 0)
EndSelect
EndProcedure
; app's main window
Procedure frmMain_Open()
If OpenWindow(#frmMain, 0, 0, 400, 300, "parent", #PB_Window_ScreenCentered)
ButtonGadget(#frmMain_btnChild, 10, 10, 150, 30, "Show Child")
EndIf
EndProcedure
; main window's gadget handlers
Procedure frmMain_onGadget(nGadget, nEventType, nX, nY)
Select nGadget
Case #frmMain_btnChild
frmChild_Open()
EndSelect
EndProcedure
; gadget events - routing to relevant window
Procedure Events_Gadget()
nGadget = EventGadget()
nEventType = EventType()
nX = 0 : nY = 0
Select GadgetType(nGadget)
Case #PB_GadgetType_Canvas
nX = GetGadgetAttribute(nGadget, #PB_Canvas_MouseX)
nY = GetGadgetAttribute(nGadget, #PB_Canvas_MouseY)
Case #PB_GadgetType_ListIcon
nY = GetGadgetState(nGadget)
; etc...
EndSelect
Select EventWindow()
Case #frmMain
frmMain_onGadget(nGadget, nEventType, nX, nY)
Case #frmChild
frmChild_onGadget(nGadget, nEventType, nX, nY)
EndSelect
EndProcedure
; windows' close events
Procedure Events_CloseWindow()
nWin = EventWindow()
Select nWin
Case #frmMain
End ; closing main window quits app
Default
CloseWindow(nWin)
EndSelect
EndProcedure
BindEvent(#PB_Event_Gadget, @Events_Gadget())
BindEvent(#PB_Event_CloseWindow, @Events_CloseWindow())
frmMain_Open()
Repeat
nWait = WaitWindowEvent()
ForEver
Nice and clean, thaks for sharingthe.weavster wrote: Thu Sep 22, 2022 6:58 pm It's been a while since I did anything involving PB gadgets (recently I've tended to make application servers with an HTML ui) but this skeleton shows how I liked to layout code for apps with multiple windows:
Hi David. Thank you for saying so. I'm glad you found it helpful.radsoft wrote: Fri Sep 09, 2022 10:55 am... It was the events handling tutorial by TI-994A that got me on a new path to gaining success with PureBasic, thank you TI-994A.