Closing a window when opening another!
BlitzPlus Forums/BlitzPlus Programming/Closing a window when opening another!
| ||
Apologies if this is a really stupid question, but.... I have a window with two buttons on it, when I click on one of the buttons another window is opened. This second window has an exit button on it which is directed back to the first window. My problem is that the first window does not close when the second is opened and when I exit the second window it creates a new version of the first window, so in a very short time I have lots of window which are not active but can be brought to the front. This program needs to be idiot proof so having these redundant windows is a nono. Anybody any ideas with this. Thanks, 3Ddoofus |
| ||
I don't believe it!!! It obviously was a stupid question because within minutes of posting I stumbled on the answer. I only posted in the first place cos I have been struggling with this for the last couple of hours. Can you credit it. As you can probably guess I'm pretty new at this programming lark. Think I'll go and lie down for a while! |
| ||
Im still a bit new at this, but try Freegadget window1 after your button click but before you create the 2nd window. I chucked this together using GUI maker...Global Win1 Global Win2 Global Button1 ;open window 2 from within window 1 Global Button2 ;open window 1 from within window 2 Global Button3 ;common exit button. CreateWin1() While WaitEvent()<>$803 If EventSource() = Button1 Then createWin2() FreeGadget Win1 End If If EventSource() = Button3 Then createWin1() FreeGadget Win2 End If If EventSource() = Button2 Then End Wend Function CreateWin1() Win1 = CreateWindow("Window1",0,0,674,528,Desktop(),3) Button1 = CreateButton("Open Window2",373,241,100,20,Win1,0) SetGadgetLayout Button1,1,0,1,0 createexitbutton(Win1) End Function Function CreateWin2() Win2 = CreateWindow("Window2",54,127,674,528,Desktop(),3) Button3 = CreateButton("Open Window1",373,241,100,20,Win2,0) SetGadgetLayout Button3,1,0,1,0 createexitbutton(Win2) End Function Function createexitbutton(window) Button2 = CreateButton("Exit",178,240,100,20,window,0) SetGadgetLayout Button2,1,0,1,0 End Function |
| ||
oops..the comments on the buttons are the wrong way around, button2 is the exit button :) |