Re: what window had focus last

new topic     » goto parent     » topic index » view thread      » older message » newer message

----- Original Message -----
From: "Judith" <camping at txcyber.com>
To: "EUforum" <EUforum at topica.com>
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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu