How to EVENT_WINDOWCLOSE
BlitzMax Forums/MaxGUI Module/How to EVENT_WINDOWCLOSE| 
 | ||
| When I have multiple windows showing and each one has it's own windowclose event how to I only close the window that the user has chosen to close? It appears my splash screens are closing out other windows. | 
| 
 | ||
| Check EventSource(). | 
| 
 | ||
| Example: Only the first window closes the application | 
| 
 | ||
| when i was doing this i did a sort of ugly hack 
Repeat 
 WaitEvent()
 Select EventID()
  Case EVENT_GADGETACTION
   Select EventSource()
    Case mySetPassword
         Local myChildWindow:TGadget         = CreateWindow:TGadget( "Password", 113, 96, 376, 121, myWindow, WINDOW_TITLEBAR | WINDOW_CHILD )
         Local myPasswordEntry:TGadget       = CreateTextField:TGadget( 32, 25, 302, 20, myChildWindow, TEXTFIELD_PASSWORD )
         Local myOk:TGadget                  = CreateButton:TGadget( "Ok", 133, 59, 104, 22, myChildWindow, BUTTON_OK )
         Local myLabel:TGadget               = CreateLabel:TGadget( "Enter Password", 32, 3, 301, 14, myChildWindow, Null ) 
         Local mySelection:Int               = Null 
         Repeat 
           WaitEvent()
            Select EventID()
             Case EVENT_GADGETACTION
              Select EventSource()
               Case myOk   
                myPassword = GadgetText( myPasswordEntry ) 
                HideGadget( myChildWindow )
                FreeGadget( myChildWindow )
                mySelection = 1
              EndSelect 
           EndSelect
         Until mySelection = 1  
   End Select 
 End Select 
Forever
ROFL i should realy read things before posting <- slaps head oh well ill leave that code here any way :p | 
| 
 | ||
| well infact you could just put an ok button on the splash screen and use the above code | 
| 
 | ||
| This is what my window call looks like. Method add_info(title_name:game, x_pos:Int, y_pos:Int) Local info_window:TGadget = CreateWindow(title_name.name, x_pos, y_pos + 32, 320, 240, Null, WINDOW_TITLEBAR) Local info_gadget:TGadget = CreateTextField(10, 10, 295, 190, info_window) SetGadgetText(info_gadget, title_name.comments) Select EventID() Case EVENT_WINDOWCLOSE If EventSource() = info_window title_name.comments = info_gadget.GetText() FreeGadget(info_window) EndIf EndSelect End Method It first refuses to close then shuts down the 2 unrelated windows behind it. |