I have been trying to find how to only close a 2nd window (about) by left click on the X but it always exits the program for the various ways I have tried.
I have a program with a menu, the menu has "File" which when clicked on shows a sub-menu with "About", a separator line, and "Exit".
the "Exit" obviously exits the program, as does clicking on the X on the main form.
When selecting the "About" a second window is opened and displays an image. Then when clicking on the X of the About window the program exits instead of just closing the About window. I need to be able to click on the About window X and have it only close the About window.
I have been trying to get this to work for 3 days (not 24hrs/day) now and have gotten nowhere. I can't get a grasp of how the event loop deals with menu items.
My current portion of code is below. This is the last issue I need to resolve with the program I am working on. Everything else is working fine.
Any help is appreciated
Code: Select all
Repeat
EventID =WaitWindowEvent()
MenuID =EventMenu()
GadgetID =EventGadget()
WindowID =EventWindow()
Select EventID
Case #PB_Event_CloseWindow ;close window event
Select WindowID
Case #Window_Launch_VNC_Form1
quitLaunch_VNC_Form1=1
EndSelect
EndSelect
Select MenuID
Case #PB_Event_Menu ;menu item Exit
Case #MenuBar_Launch_VNC_Form1_Exit
Select EventType()
Case #PB_EventType_LeftClick
QuitLaunch_VNC_Form1=1
EndSelect
Case #MenuBar_Launch_VNC_Form1_About
Select EventType()
Case #PB_EventType_LeftClick
LoadImage(0,"D:\basic\arcsver\About2.bmp",0) ;load "About" image
OpenWindow(#Window2, 470, 300, 378, 237, "About Some Program", #PB_Window_SystemMenu) ;open new "About" window
ContainerGadget(#AboutContainer, 0, 0, 378, 237) ;create container gadget
SetBackgroundImage(#AboutContainer, 0) ;call procedure to show image in window
EndSelect
Case #MenuBar_Launch_VNC_Form1_About
Select EventType()
Case #PB_Event_CloseWindow
CloseWindow(#Window2)
EndSelect
EndSelect
Select GadgetID
Case #PB_Event_Gadget
Case #Gadget_Launch_VNC_Form1_Image_1
Select EventType()
Case #PB_EventType_LeftClick
Default
EndSelect
;
; a lot of (90) Button Gadget code is not shown here as it is not necessary for debugging
;
Until quitLaunch_VNC_Form1 ;end of repeat until
CloseWindow(#Window_Launch_VNC_Form1)