Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to detect when a VB app has been switched to 5

Status
Not open for further replies.

JNeave

Programmer
Jan 28, 2002
125
GB
Inside VB you get the GotFocus and Activate events on a form.

But neither of these get called if you switch from, say, Notepad to the VB app you have written.

Is there any way to detect this?

Cheers,

Jim.
 
For readers of this code:
1. In the error checking for the UnHook I left out one line after the
lpPrevWndProc = SetWindowLong(....)

lpPrevWndProc = 0

2. Change the Gc0 to 0
(I use Gc0% as a constant for the number 0)

3. The purpose of the additional error checking is so that if you decide to use the code for other reasons, that you do not forget to Unhook before hooking again, and to make sure the same hWnd is used for unhooking, that was used with hooking.

4. There are many other possibilities to use this. You can capture almost anything you would expect and more(WM_LBUTTONDOWN mouse,WM_KEYDOWN keyboard, CBN_DROPDOWN the list box portion of a combo box "BeforeVisible" event, etc, etc, etc. - check constants in the API viewer) of a window.

5. If you want to cancel proccessing of an event then after capturing it in the WindowProc, set the return value of the function to WindowProc = Gc1, and the event will never execute in the window's (form or control) event.


To StrongM:
I only wanted users of this code to be aware when not using error checking, but didn't want to impose on your great explaination, but rather, leave that up to you....Esp. if someone doesn't use it only in this way, but in addition to other possibilities, which could cause problems if not Hooked/Unhooked when properly.[medal] [rockband]




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top