Detecting A Window Coming To The Front

awesp

New Member
Hello,

I have several windows open and would like to detect when one of them is made the frontmost. Progress does not seem to have an event for this. It has WINDOW-CLOSE, WINDOW-RESIZED, etc, but no 'BRING-TO-FRONT' event. Is there a way of detecting when a window is brought to the front and made the 'active' window?

Thanks for any tips/suggestions.

Adam
 

awesp

New Member
Hello Oli,

Thanks for your prompt response.

Yes, I'm using the ENTRY event, but doesn't seem top work all the time. I was just thinking that there could be other options.

Best regards,

Adam
 

Osborne

Active Member
I don't know if this is any use, but one suggestion I once saw for something similar to what you are asking for is use the API call GetForegroundWindow and a .NET timer to constantly check the windows and check which one is the front one. I think it was a Visual Basic solution but unfortunately cannot find it.

If GetForegroundWindow may be a solution then a very simple example is:
Code:
DEFINE VARIABLE intHandle AS INTEGER NO-UNDO.

PROCEDURE GetForegroundWindow EXTERNAL "USER32.DLL":
    DEFINE RETURN PARAMETER intHandle AS LONG.
END PROCEDURE.

RUN GetForegroundWindow(OUTPUT intHandle).

MESSAGE "Foreground Window Handle is " intHandle VIEW-AS ALERT-BOX.
 
Top