This is making me feel a bit dense and frustrated.
I can't figure out how to respond and quit when Quit is chosen from the Application menu.
My app so far is super simple. I'm just trying to wrap my head around using the Forms Designer and how to created gadgets, events, and respond to them.
My form code is like this:
Code: Select all
;
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;
Global Window_0
Global Button_0, String_0
Declare sayHello(EventType)
Procedure OpenWindow_0(x = 0, y = 0, width = 600, height = 400)
Window_0 = OpenWindow(#PB_Any, x, y, width, height, "Hello, World.", #PB_Window_SystemMenu)
Button_0 = ButtonGadget(#PB_Any, 250, 350, 100, 25, "Click Me")
String_0 = StringGadget(#PB_Any, 10, 140, 570, 25, "")
EndProcedure
Procedure Window_0_Events(event)
Select event
Case #PB_Event_CloseWindow
ProcedureReturn #False
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case Button_0
sayHello(EventType())
EndSelect
EndSelect
ProcedureReturn #True
EndProcedure
Code: Select all
XIncludeFile "Hello World.pbf"
OpenWindow_0()
Procedure sayHello(x)
SetGadgetText(String_0, "Hello, World.")
EndProcedure
Repeat
event = WaitWindowEvent()
Window_0_Events(event)
Until event = #PB_Event_CloseWindow
Code: Select all
Until event = #PB_Event_CloseWindow Or event = #PB_Menu_Quit
I even tried making my Repeat loop like this:
Code: Select all
Repeat
If event = #PB_Menu_Quite
Break
Else
event = WaitWindowEvent()
Window_0_Events(event)
EndIf
Until event = #PB_Event_CloseWindow
Then, I tried making a menu in the Forms Designer and adding a menu item to it and setting the constant of the menu item to be #PB_Menu_Quit and that did not compile but threw an error telling me that #PB_Menu_Quit is already defined.
I clearly don't understand what I'm reading in the documentation and what the best way to make my Hello World respond to selecting Quit from the Application menu is.
Help would be appreciated. Thanks.