Solved

how to know when my VB app has the focus?

Posted on 2001-09-13
3
168 Views
Last Modified: 2006-11-17
Hi,

I have a VB app that needs to know when the user goes to another app while still leaving mine running. Is there anyway to do this? I tried Get/Lost_Focus, and Activate and Deactivate events, but they only let me know when a user is switching between forms in the SAME app.

Thanks
0
Comment
Question by:jhamlett
3 Comments
 
LVL 2

Accepted Solution

by:
dhodge earned 100 total points
ID: 6480619
put a timer on your control, on the timer event get the activewindow if it doesn't match the handle to yuor app you have lost the focus.

Declare Function GetActiveWindow Lib "user32" () As Long
0
 
LVL 2

Expert Comment

by:JanusFury
ID: 6480673
when he says handle he means hWnd.
and if you have multiple forms in your app, you'll have to compare the value returned by GetActiveWindow with all the hWnd's in your app instead of just one.
0
 

Author Comment

by:jhamlett
ID: 6480748
cool, thanks-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now