Find which form has the focus

Within my project, i'm looking to find whether

a) my application has the current focus and
b) if so, which form within my application has the current focus.

for b) i'd like to use the Forms collection if possible ..

i'd like to stay away from having to use a Global declaration to track which form has the current focus by using the Activate() event.  That just feels like bad programming =\
selectgtAsked:
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.

f8bluemistCommented:
well selectgt, thats very very simple...just use global declaraion to track which form has the current focus!
enjoy!
0
SethiCommented:
Use Screen.ActiveForm.Name to know the active form in your application
0
venyonCommented:
This article should answer your question regarding application focus: http://support.microsoft.com/default.aspx?scid=KB;en-us;q186908

Now for the forms within your application, ff you're using MDI forms, you may use the ActiveForm property to return the active child form. If you're using non-MDI forms, then you may still use Screen.ActiveForm to find out about the same thing.

Hope this helps!
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

SethiCommented:
Screen.ActiveForm.Name can be used with both MDI and SDI applications.
0
selectgtAuthor Commented:
does screen.activeform.name tell me whether or not my application in general is focused?
0
SethiCommented:
Yes it will, becuase whenever your application is focused you will have one of the forms in the application with the focus and this method will tell you that.
0
selectgtAuthor Commented:
Sethi: I also wanted to know when my application didn't have the focus as well.  You solved half my problem, and thank you for that.. but the entire question was answered by venyon and his solution did work for me.


Thanks a bunch you guys.
0
selectgtAuthor Commented:
Thank you kind sir, this was exactly what I needed.
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.