delphi - Detect what window was active just before my app activates -


in delphi xe, i'm trying use getforegroundwindow detect window active before application activated. "activated" means app may have been restored iconic state, or switched via alt+tab, or brought activaton hotkey, etc.

the problem available application events (onactivate, onrestore) come late, getforegroundwindow returns own form's handle. main form's events less useful. processing wm_activateapp in main form happens late, too.

one way keep checking active window on timer while application not active, seems rather wasteful. better solution subclass tapplication.wndproc , thing before wm_activateapp processed, don't think tapplication can subclassed.

is there better way?

when application activates, becomes topmost window. iow, jumps top z-order position.

with this, previous topmost window demoted "just below new topmost window" position. iow, becomes second in z-order position.

calling getnextwindow , passing handle of form , gw_hwndnext may give result need.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -