Click to See Complete Forum and Search --> : Form losing mouse


eric33
August 17th, 2001, 02:27 AM
How could i detect that a form lost the mouse focus, it means the mouse move on another part but not on the form.

How could i detect that another form takes the focus.

Note that the other form could be a form of another application.

thanks

Clearcode
August 17th, 2001, 02:46 AM
To detect that focus has shifted to/from your application you should get the VBEventCTL.ocx control from http://www.merrioncomputing.com/Download/index.htm

Drop the VBEventWindow control from that package onto your app's amin form and in the form load put:

private Sub Form_Load()

VBEventWindow1.ParentForm = me.hWnd

End Sub




Then whatever code you want to execute when your app gains or loses the focus should go in the ActiveApplicationChanged event:

private Sub VBEventWindow1_ActiveApplicationChanged(byval ActivatingThisApp as Boolean, byval hThread as Long, Cancel as Boolean)

If ActivatingThisApp then
'My program is regaining focus
else
'My program is losing focus to hThread program
End If

End Sub




HTH,
Duncan

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.