>I'm looking for a way for my FoxPro app to detect that the user has switched to another Windows app, desktop or whatever. Also, detect when the FoxPro app becomes the active app again.
>
>I'll need to have FoxPro trigger a function in both events.
>
>Any suggestions ?
>
>- Werner
Hi Werner,
The easiest way to deal with this is to first load foxtools. If you're using the main VFP window, retrieve it's window handle using the MainhWnd() function, other use _WHToHwnd(_WFindTitl(ThisForm.Caption)) to get that. Assuming that you've main the active VFP window handle (either _SCREEN's or Form) as a property of the object (in the example a form) that has the timer, then the following does what you need:
DECLARE INTEGER GetForegroundWindow IN Win32API
LOCAL lnhWnd
lnhWnd = GetForegroundWindow()
IF lnhWnd # = ThisForm.hWnd
ELSE
ENDIF
hth,
George
Ubi caritas et amor, deus ibi est