Page 1 of 1
Posted: Mon Feb 17, 2003 7:52 pm
by BackupUser
Restored from previous forum. Originally posted by geoff.
The help file says the function UseWindow() makes the specified
window the currently used window, however I'm rather unsure about
when to include this command.
I had window 1 with a popup menu and then opened window 2. Then I
closed window 2 and found that the menu on window 1 would not operate.
This problem was solved by putting a UseWindow(1) after the CloseWindow(2).
OK, but if I have several windows open, does this mean that Gadgets
and menus will only work on the window which last had a UseWindow()
command executed?
I can't put the UseWindow() command in the PureBasic event handler
because this only seems to run for the current window selected by
the last UseWindow() command. So what's the best way to
use the command UseWindow() when you have multiple windows?
Posted: Mon Feb 17, 2003 8:54 pm
by BackupUser
Restored from previous forum. Originally posted by plouf.
this propably is a wrong on the way you catch up events
i have a program that opens and closes a lot of windows
and independely the window you open/close the window you click
has correct affect to menus/gadgets
Christos
Posted: Mon Feb 17, 2003 8:59 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
> what's the best way to use the command UseWindow() when you have multiple windows?
UseWindow() tells your app which window's event loop to use. So when
you open a new window, this new window's event loop is automatically
used. When you close this window, you use UseWindow() to specify
which window's event loop will now be used.
Posted: Mon Feb 17, 2003 11:28 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.
IIRC, Gadget indexes are unique. So don't use the same gadget index for different gadgets, even if they are in different GadgetLists. I'm not so sure for menu items. Anyway, now that I'm writing, what about support for child windows in PB? SetParent_() doesn't do the job correctly.
Bye,
El_Choni
Posted: Tue Feb 18, 2003 12:27 pm
by BackupUser
Restored from previous forum. Originally posted by Manolo.
See the next example from Danilo:
Code: Select all
#ID_MWindow =0 ; Mother
#ID_SWindow =1 ; Second
#ID_Button1 =10
#ID_Button2 =11
Procedure openwindow2()
hnd_SWindow=OpenWindow(#ID_SWindow,200,200,200,200,0,"Second Window")
If CreateGadgetList(hnd_SWindow)
ButtonGadget(#ID_Button2,50,50,50,20,"Exit")
EndIf
EndProcedure
hnd_MWindow=OpenWindow(#ID_MWindow,100,200,200,200,#PB_Window_SystemMenu,"Test")
If CreateGadgetList(hnd_MWindow)
ButtonGadget(#ID_Button1,50,50,50,20,"Open")
EndIf
Repeat
Event = WaitWindowEvent()
If Event=#PB_EventGadget
Select EventGadgetID()
Case #ID_Button1: openwindow2()
Case #ID_Button2: CloseWindow(#ID_SWindow)
EndSelect
EndIf
Until Event=#PB_Event_CloseWindow And EventWindowID() = #ID_MWindow
Use the option SEARCH in the forum panel for searh solutions to you questions. Is very easy. And if this not exist ask to the forum.
Regards,
Manolo
Posted: Tue Feb 18, 2003 12:53 pm
by BackupUser
Restored from previous forum. Originally posted by geoff.
Thank you all for your help.
Yes I see PB. The purebasic event handler works for the current selected window. That makes sense.
I also use a callback Windows message handler. This works all the time but of course the incoming Windows messages contain a window handle as there first parameter. It was the PureBasic event handler that caught me out.
Cheers,
Geoff