Solved

how to know when my VB app has the focus?

Posted on 2001-09-13
3
167 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

707 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

15 Experts available now in Live!

Get 1:1 Help Now