?
Solved

Find which form has the focus

Posted on 2003-02-19
8
Medium Priority
?
204 Views
Last Modified: 2010-05-01
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 =\
0
Comment
Question by:selectgt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 

Expert Comment

by:f8bluemist
ID: 7984531
well selectgt, thats very very simple...just use global declaraion to track which form has the current focus!
enjoy!
0
 
LVL 18

Expert Comment

by:Sethi
ID: 7984720
Use Screen.ActiveForm.Name to know the active form in your application
0
 
LVL 3

Accepted Solution

by:
venyon earned 400 total points
ID: 7984731
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:Sethi
ID: 7992231
Screen.ActiveForm.Name can be used with both MDI and SDI applications.
0
 

Author Comment

by:selectgt
ID: 7992408
does screen.activeform.name tell me whether or not my application in general is focused?
0
 
LVL 18

Expert Comment

by:Sethi
ID: 7997288
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
 

Author Comment

by:selectgt
ID: 7998206
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
 

Author Comment

by:selectgt
ID: 7998207
Thank you kind sir, this was exactly what I needed.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question