Looking for 'Application Lost Focus' event 
Author Message
 Looking for 'Application Lost Focus' event

Hi,
I'm looking for a way to know when my VB6 application has lost focus to
another application.  I have a form that acts as a toolbox and is set to be
AlwaysOnTop, but I need to set it as a normal window if another application
has focus.
Thanks.


Sun, 02 Dec 2001 03:00:00 GMT  
 Looking for 'Application Lost Focus' event
Tony,

The only way to do that is to subclass your form and look for WM_ACTIVATE and/or
WM_APPACTIVATE messages.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please post/reply to the newsgroup(s) so
that everyone can benefit from the discussion.

Klaus H. Probst, MCP

       ICQ: 22454937
      The VB Box: http://members.xoom.com/kprobst/
~~~~~~~~~~~~~~~~~~~~~~~~~~~


Quote:
> Hi,
> I'm looking for a way to know when my VB6 application has lost focus to
> another application.  I have a form that acts as a toolbox and is set to be
> AlwaysOnTop, but I need to set it as a normal window if another application
> has focus.
> Thanks.



Sun, 02 Dec 2001 03:00:00 GMT  
 Looking for 'Application Lost Focus' event
Thanks Galen!  I didn't know I could pass the parent in the Show method.
I've used the API call since VB3 and I guess it's been a while since I've
looked up 'Show' in the docs.  Thanks again.
- Tony


Quote:
> Hi Tony.  How about using:
> frmOnTop.Show , frmParentForm
> rather than the SetWindowPos API?

> If you can't use that, then another API alternative is the following:

> Private Declare Function SetWindowLong Lib _
> "user32" Alias "SetWindowLongA" _
> (ByVal hwnd As Long, _
> ByVal nIndex As Long, _
> ByVal dwNewLong As Long) As Long

> Private Const SWW_HPARENT = -8

> 'frmParent's Load Event
> frmOnTop.Show
> Call SetWindowLong(frmOnTop.hwnd, _
> SWW_HPARENT, frmParent.hwnd)

> Those should control your focus issues.

> Another option:

> HOWTO: Determine When Your Application Gains or Loses Focus
> Article ID: Q186908
> http://support.microsoft.com/support/kb/articles/q186/9/08.asp

> '-------
> galen



Mon, 03 Dec 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. display back 'lost' application

2. Timer Event won't fire when app doesn't have focus

3. Timer Event won't fire when app doesn't have focus

4. lost focus and got focus event

5. UserControl's parent losing focus

6. checking for click event during lost focus event

7. Form close event occurs before lost focus event

8. Focus, Focus, Who's getting the Focus

9. HELP - I've lost my Event Procedures!!!

10. keyboard events when form doesn't have the focus

11. How to know which object was focused before another control's event

12. Softkeyboard application can't take focus

 

 
Powered by phpBB® Forum Software