
I'm attempting to get a feel with handling the gui, so I'm trying out different things, however something that has stumped me is a disappearing gui when I dynamically add controls.
Here's what I have:
Code: Select all
EnableExplicit
Enumeration
#Window_Main
EndEnumeration
Enumeration
#ScrollArea_0
#Hyperlink_Test
EndEnumeration
Procedure Open_Window_Main()
If OpenWindow(#Window_Main, 0, 0, 640, 480, "Central", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
If CreateGadgetList(WindowID(#Window_Main))
HyperLinkGadget(#Hyperlink_Test, 20, 20, 80, 30, "Test", RGB(0, 0, 0))
ScrollAreaGadget(#ScrollArea_0, 120, 10, 520, 460, 640, 480, 20, #PB_ScrollArea_Single)
CloseGadgetList()
EndIf
EndIf
EndProcedure
Procedure HelloWorld()
Enumeration
#btnHelloWorld
#btnQuit
EndEnumeration
OpenGadgetList(#ScrollArea_0)
ButtonGadget(#btnHelloWorld, 50, 50, 80, 40, "Hello World")
ButtonGadget(#btnQuit, 0, 0, 80, 30, "Quit")
CloseGadgetList()
Protected Event
Protected WindowID
Protected GadgetID
Protected EventType
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadget() ; Is it a gadget event?
EventType = EventType() ; The event type
If Event = #PB_Event_Gadget
If GadgetID = 0
MessageRequester("Test", "Hello World", #PB_MessageRequester_Ok)
EndIf
EndIf
Until Event = #PB_Event_CloseWindow Or Event = #PB_Event_Gadget And GadgetID = #btnQuit ; End of the event loop
If Event = #PB_Event_CloseWindow
End
EndIf
FreeGadget(#btnHelloWorld)
FreeGadget(#btnQuit)
EndProcedure
Procedure Main()
Open_Window_Main()
Protected Event
Protected WindowID
Protected GadgetID
Protected EventType
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadget() ; Is it a gadget event?
EventType = EventType() ; The event type
If Event = #PB_Event_Gadget
If GadgetID = #Hyperlink_Test
HelloWorld()
EndIf
EndIf
Until Event = #PB_Event_CloseWindow ; End of the event loop
EndProcedure
Main()
End
;
What happens (at least for me) is that all the gadgets disappear. All I can do is just close the window.
Any clues?