How do I detect the focus going to another window

Do this..
create a blank form and run it.
next to it put another open window (control panel) so both are on the desktop not overlapping.
highlight the "control bar" on the control panel windo.
the "control bar" on the Form1 window goes "grey".
How do I detect that that has happend in my Form1 program?
And..when detected, how to I shif the focus back to the Form1 app?
rbenderAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rbenderAuthor Commented:
10 is all I have left.
0
rbenderAuthor Commented:
Edited text of question.
0
VbmasterCommented:
Have you checked the Form_LostFocus() event?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

rbenderAuthor Commented:
I did..
I put form1.caption = "I'm Gone"
in that event but nothing seemed to happen when I moved to the other window.
0
mcriderCommented:
You can use the following code in a timer or call it yourself.  The example is in a timer event:

Private Declare Function GetActiveWindow Lib "user32" () As Long
Public ActiveWindow As Long
Private Sub Timer1_Timer()
ActiveWindow = GetActiveWindow
If ActiveWindow <> Form1.hwnd Then
    AppActivate App.Title
End If
End Sub


Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Erick37Commented:
I think you will find your answer here:

"HOWTO: Determine When Your Application Gains or Loses Focus"

http://support.microsoft.com/support/kb/articles/Q186/9/08.ASP
0
mcriderCommented:
Thanks for the points! Glad I could help!


Cheers!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.