RE: what window had focus last
Thanks, Derek,
But when I took the next logical step and added an EditText control to
winc. I added a test of lFocus in onResize[winm] within a test on
SIZE_RESTORE and then set focus to winc, if that was the value in
lFocus, but the child window is not highlighted. Setting focus to the
EditText instead of winc does not place the cursor inside the edit box
and besides winm still has *visual* vocus since it is highlighted. The
user would like to see the child window exactly as he left it before
minimizing winm. Am I up a creek here?
Judith
Derek Parnell wrote:
> ----- Original Message -----
> From: "Judith" <camping at txcyber.com>
> To: "EUforum" <EUforum at topica.com>
> Sent: Tuesday, September 04, 2001 9:24 PM
> Subject: what window had focus last
>
> > If a program has several windows with the secondary windows having the >
> main window as parent and any number of them might be open at any time,
> > is there an easy way to know which one had focus before the ap is
> > minimized? I realise I could be setting values in a variable but I was >
> wondering if there is something in the API that might help me.
>
>
> Hi Judith,
> see if this helps you ...
> --------------------------
> include win32lib_full.ew
> without warning
>
> constant
> xGetFocus = registerw32Function(user32, "GetFocus", {},C_ULONG),
> xGetForegroundWindow = registerw32Function(user32,
> "GetForegroundWindow", {}, C_ULONG)
>
> constant
> winm = create(Window, "Main Window", 0, 0, 0, 400, 400, 0),
> SB = create(StatusBar, "", winm, 0, 0, 0, 0, 0),
> winc = create(Window, "Child Window", winm, 300, 300, 300, 300, 0),
> btnc = create(Button, "child button", winc, 5, 5, 150, 25,0),
> btnm = create(Button, "main button", winm, 5, 5, 150, 25, 0)
>
>
> openWindow(winc, 0)
>
> procedure showfocus(integer self, integer event, sequence parms)
> integer lFocus, lFore
> sequence lForeText, lFocusText
>
> lFocus = getId(w32Func(xGetFocus,{}))
> lFore = getId(w32Func(xGetForegroundWindow,{}))
>
> lForeText = getText(lFore)
> lFocusText = getText(lFocus)
>
> setText(SB,
> sprintf("Focus = '%s', Foreground = '%s'",
> {lFocusText, lForeText }))
> end procedure
> setHandler({btnc,btnm}, w32HClick, routine_id("showfocus"))
>
> WinMain(winm, 0)
> -----------------
>
>
> ----------
> Derek
>
>
|
Not Categorized, Please Help
|
|