Solved

how to know when my VB app has the focus?

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

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 …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

808 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