1. Re: setFocus()
- Posted by Derek Parnell <ddparnell at bigpond.com> Nov 25, 2002
- 426 views
----- Original Message ----- From: "Wolf" <wolfritz at KING.IGS.NET> To: "EUforum" <EUforum at topica.com> Subject: re: setFocus() > > Forgot to ask, ages ago, why this doesn't even work anymore. > > include win32lib.ew -- ver. 0.55+ > constant > mywin=create(Window,"TestFocus",0,10,10,200,200,0), > btn1=create(PushButton,"One",mywin,10,10,60,25,0), > btn2=create(PushButton,"Two",mywin,10,50,60,25,0) > showWindow(mywin,SW_NORMAL) > setFocus(btn2) > WinMain(mywin,Normal) > ----end---- > > I've tried 'wrapping' the setFocus() in an onOpen(), > used setVisible()'s, > tried without showWindow(), > etc, and it still don't wanna... > The WinMain() call does an internal openWindow() call, and inside that routine, setFocus() is used to focus on the newly opened window. Thus any setFocus() you do prior to the WinMain() is lost. To achieve the effect you are after, use the Activate event instead. This event is invoked after a window is opened and just before control is returned to the application. include win32lib.ew -- ver. 0.55+ constant mywin=create(Window,"TestFocus",0,10,10,200,200,0), btn1=create(PushButton,"One",mywin,10,10,60,25,0), btn2=create(PushButton,"Two",mywin,10,50,60,25,0) procedure Activate_mywin(integer self, integer event, sequence parms) setFocus(btn2) end procedure setHandler(mywin, w32HActivate, routine_id("Activate_mywin")) WinMain(mywin,Normal) ---------------- cheers, Derek Parnell