Find out if my app is the active app 
Author Message
 Find out if my app is the active app

Hello,

From my application's code, I need to know if my app is the active app of
the system at that moment (that is, the app that has the "focus"). I browsed
the Win32 API documentation, but didn't find a function that returned the
active app.
Does anyone know how can I achieve this?

Thanks in advance,

Leonardo Bosi
Proximity Soft
Buenos Aires, Argentina
--------------------------------------------

http://www.*-*-*.com/



Mon, 21 Oct 2002 03:00:00 GMT  
 Find out if my app is the active app
Hi Leonardo,

Try the GetForegroundWindow() API.

Declare Function GetForegroundWindow Lib "user32" Alias "GetForegroundWindow" ()
As Long

You can check if your app is active like this:

If MyForm.hWnd = GetForegroundWindow() then
    'App is active
  Else
    'Some other app is active
End if

Also, you can subclass your window and process the WM_ACTIVATEAPP message to
find when your app is being activated or deactivated.

Regards,
               Stoil

Quote:

> Hello,

> From my application's code, I need to know if my app is the active app of
> the system at that moment (that is, the app that has the "focus"). I browsed
> the Win32 API documentation, but didn't find a function that returned the
> active app.
> Does anyone know how can I achieve this?

> Thanks in advance,

> Leonardo Bosi
> Proximity Soft
> Buenos Aires, Argentina
> --------------------------------------------

> http://www.proximity.com.ar



Mon, 21 Oct 2002 03:00:00 GMT  
 Find out if my app is the active app
Hi Leonardo,

You could use the GetForegroundWindow api and compare the returned handle
with your form's handle.  Also you may need to use the GetParent api on the
returned handle (not sure), if the returned handle is a child window, then
compare the window's handle with your form's handle.

Bill


Quote:
> Hello,

> From my application's code, I need to know if my app is the active app of
> the system at that moment (that is, the app that has the "focus"). I
browsed
> the Win32 API documentation, but didn't find a function that returned the
> active app.
> Does anyone know how can I achieve this?

> Thanks in advance,

> Leonardo Bosi
> Proximity Soft
> Buenos Aires, Argentina
> --------------------------------------------

> http://www.proximity.com.ar



Tue, 22 Oct 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Finding app, closing app using API

2. App not finding dll in app folder in Vista x64

3. Active program: keeping the app active and checking time

4. Is Word app active?

5. Checking for Active Word App

6. Problem whit Active-X database app.

7. App Active

8. Identifying the active form in an MDI App

9. Check for active app

10. Active Apps Caption.

11. ADDING ACTIVE X APPS TO THE WEB

12. drag and drop from vb 5 app to the desktop (active and normal)

 

 
Powered by phpBB® Forum Software