This can be seen if lines denoted First and Second are reversed. While there is nothing wrong with it, understanding the reason would be useful. Thanks.
Code: Select all
EnableExplicit
Global Main_Window, ChildWindow, ListGadget
Define Event
Enumeration SpecialKeys
#EntKey
#EscKey
EndEnumeration
Procedure OpenSecondWindow()
ChildWindow = OpenWindow(#PB_Any, 25, 475, 450, 300, "Second window, press ESCAPE to close", #PB_Window_ScreenCentered)
ListGadget = ListIconGadget(#PB_Any, 5, 5, 475, 300, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(ListGadget, 1, "Address", 250)
AddGadgetItem(ListGadget, -1, "Record 1"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(ListGadget, -1, "Record 2"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
AddKeyboardShortcut(ChildWindow, #PB_Shortcut_Escape, #EscKey) ; ESC shortcut (close window)
DisableWindow(Main_Window, #True) ; Disable the main window
EndProcedure
Main_Window = OpenWindow(#PB_Any, #PB_Ignore, #PB_Ignore, 500, 400, "Main window, Press ENTER to open second window", #PB_Window_MinimizeGadget | #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
AddKeyboardShortcut(Main_Window, #PB_Shortcut_Return, #EntKey) ; ENTER shortcut (open second window)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Menu
Select EventMenu()
Case #EscKey
If IsWindow(ChildWindow)
DisableWindow(Main_Window, #False) ; <-------------------- First
CloseWindow(ChildWindow) ; <-------------------- Second
EndIf
Case #EntKey
If Not IsWindow(ChildWindow) ; Don't open second window
OpenSecondWindow()
EndIf
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
; Events
EndSelect
EndSelect
ForEver

