I have a main window with a menu. And in two other files I have two other windows. I can open one or the other of the two windows. I can not open an other of the two extra windows. I can close the one that I opened but I can't reopen it nor the other anymore. Is there an easy way to do/ solve this? I guess applications with lots of windows and dynamicly build windows are not exceptional?
I am on a raspberry pi 5 with desktop raspbian
Code: Select all
; Main window
;Vensters globale variabel geven zodat gevolgd wordt of ze open of dicht zijn.
Global Venster1.i=-1 ;-1 is nog niet geopend
#ProgramTitle = "Boekhouding en facturatie"
#ProgramVersion = "v1.01"
Declare OpenSubWindow1()
Enumeration Windows
#Main
#Venster1
#Venster2
EndEnumeration
Enumeration MenuBar
#MainMenu
EndEnumeration
Enumeration MenuItems
#MainMenuAbout
#MainMenuExit
#MenuVenster1
#MenuVenster2
#MenuVenster3
#Menuvenster4
EndEnumeration
Enumeration Gadgets
#MainEdit
#MainButtonOk
#MainButtonCancel
EndEnumeration
Enumeration StatusBar
#MainStatusBar
EndEnumeration
;vensters
IncludeFile("venster.pb");
IncludeFile("venster2.pb")
XIncludeFile("form.pbf")
;IncludeFile("Database.pb")
Procedure UpdateWindow()
Protected dx, dy
dx = WindowWidth(#Main)
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
; Resize gadgets
ResizeGadget(#MainEdit, 5, 5, dx - 10, dy - 45)
ResizeGadget(#MainButtonok, 10, dy - 35, 120, 30)
ResizeGadget(#MainButtonCancel, dx - 130, dy - 35, 120, 30)
EndProcedure
Procedure Main()
Protected dx, dy
#MainStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, #ProgramTitle , #MainStyle)
; Menu
If CreateMenu(#MainMenu, WindowID(#Main)) ; menu creation starts....
MenuTitle("&Bestand")
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
MenuItem(#PB_Menu_About, "")
CompilerElse
MenuItem(#MainMenuAbout, "Over")
CompilerEndIf
; Menu File Items
CompilerIf Not #PB_Compiler_OS = #PB_OS_MacOS
MenuBar()
MenuItem(#MainMenuExit, "E&xit")
CompilerEndIf
;MenuTitle("&Vensters")
;MenuItem(#MenuVenster3, "Venster 3")
;MenuItem(#MenuVenster4, "Venster 4")
;OpenSubMenu("Recent files") ; begin submenu
;MenuItem( 33, "C:\Autoexec.bat")
;MenuItem( 44, "D:\Test.txt")
;CloseSubMenu()
MenuTitle("&Vensters12")
MenuItem(#MenuVenster1, "Venster 1")
MenuItem(#MenuVenster2, "Venster 2")
EndIf
; StatusBar
CreateStatusBar(#MainStatusBar, WindowID(#Main))
AddStatusBarField(#PB_Ignore)
; Gadgets
dx = WindowWidth(#Main)
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
EditorGadget(#MainEdit, 5, 5, dx -10, dy - 45)
ButtonGadget(#MainButtonok, 10, dy - 35, 120, 30, "Ok")
ButtonGadget(#MainButtonCancel, dx - 130, dy - 35, 120, 30, "Cancel")
; Bind Events
BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main)
; Event Loop
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Main
Break
EndSelect
Case #PB_Event_Menu
Select EventMenu()
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
Case #PB_Menu_About
PostEvent(#PB_Event_Menu, #Main, #MainMenuAbout)
Case #PB_Menu_Preferences
Case #PB_Menu_Quit
PostEvent(#PB_Event_CloseWindow, #Main, #Null)
CompilerEndIf
Case #MenuVenster1
OpenSubWindow1() ; Roep de subvensterprocedure aan met hoofdvenster als parent
;OpenWindow_0()
Case #MenuVenster2
OpenSubWindow2()
Case #MainMenuAbout
MessageRequester("About", #ProgramTitle + #LF$ + #ProgramVersion, #PB_MessageRequester_Info)
Case #MainMenuExit
PostEvent(#PB_Event_CloseWindow, #Main, #Null)
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #MainEdit
Select EventType()
Case #PB_EventType_Change
;
EndSelect
Case #MainButtonOk
OpenSubWindow2();
Case #MainButtonCancel
;
EndSelect
EndSelect
ForEver
EndIf
EndProcedure : Main()
Code: Select all
; Implementatie van OpenSubWindow
;subvenster maken
Procedure OpenSubWindow1()
If Venster1 = -1 Or IsWindow(Venster1) = 0
Venster1 = OpenWindow(#Venster1, 150, 150, 300, 200, "Nieuw Venster", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(3, 100, 80, 100, 30, "Sluiten")
MessageRequester("wel venster","Venster is al open",0)
Else
MessageRequester("geen venster","Venster nog niet open",0)
EndIf
; Evenementen voor het subvenster
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget And EventGadget() = 3
CloseWindow( EventWindow())
;CloseWindow(#Venster1) ; Sluit het subvenster
Venster1 = -1 ; zet terug als niet open
EndIf
Until EventID = #PB_Event_CloseWindow
EndProcedure
Code: Select all
; Implementatie van OpenSubWindow
;subvenster maken
Procedure OpenSubWindow2()
OpenWindow(#Venster2, 150, 150, 300, 200, "Nieuw Venster 2", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(4, 100, 80, 100, 30, "Sluiten")
; Evenementen voor het subvenster
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget And EventGadget() = 4
CloseWindow(#Venster2) ; Sluit het subvenster
EndIf
Until EventID = #PB_Event_CloseWindow
EndProcedure