Solved

Knowing when MOUSE HAS LEFT A Control

Posted on 1999-01-16
8
176 Views
Last Modified: 2010-05-03
Is there a way of knowing when the mouse has left a control.
I know there is an event called MouseMove() that handles when a mouse has entered into a controls region BUT is there a way of knowing when the mouse has actually left this region?
0
Comment
Question by:ljaques
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 1

Expert Comment

by:ikxsoft
ID: 1469015
just use the form_mousemove() to detect when the mouse has left the control.
since the mouse is over the form, it must have left the control!
0
 

Author Comment

by:ljaques
ID: 1469016
Problem is the FORM's MOUSEMOVE event doesnt activate when in the menu area or its title bar or its form frame (if form is resizeable -- and mine is).   I have so many controls on this form there are only tiny areas in which the form's mouse move event can actually trigger...and those areas are either the title bar, menu, or form frame...and since the event doesnt occur in those areas i am LOST...HELP!

0
 
LVL 1

Accepted Solution

by:
Johnn earned 10 total points
ID: 1469017
This is an easy on if you know the win32 api.(as long as it's a windowed control, i.e. has an hWnd property)

Just trap the WM_CAPTURECHANGED message.  The lParam tells you the handle of the window getting the focuse.

PS  In case you don't know, you need to subclass the window and intercept this msg

John
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:ljaques
ID: 1469018
Thanks...i got it working in the EXACT way you were describing!
0
 
LVL 1

Expert Comment

by:Johnn
ID: 1469019
Excellent!  You know the win32 api isn't hard at all as long as some tells you what each msg is for and when it's fired as well as how to interpret the parameters.  
I don't know why VB controls don't have this GotCapture and LostCapture event, how hard would it be(probably take less than 30 mins for each control) and obviously everyone wants these.  It's too bad VB doesn't remove the intrinsic controls from the runtime and just include the source(in VB of course) for each so we can modify them ourselves.  I just wish Delphi's IDE was as good as VB's, I'll give VB that credit.

John
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1469020
Johnn, ljaques,

I just bought this PAQ and I would be interested in knowing how exactly this was implemented. Could one of you add the code as a comment?

I'm not very comfortable with API calls so I would appreciate it if you could make this idiot proof

Thanks!
0
 
LVL 1

Expert Comment

by:Johnn
ID: 1469021
use a sub classer to subclass the control you want and do something like this.

'in the subclassers wndproc event
Select case msg
    case WM_CAPTURECHANGED
        'my mouse is losing the mouse capture
End Select


0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1469022
Hello Johnn,

Sorry, but I'm not familiar with the term subclassing - how do you subclass a control? Could you write up a simple example with a form with just one text box on it?

Much obliged.
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Suggested Courses
Course of the Month8 days, 5 hours left to enroll

617 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