Solved

Knowing when MOUSE HAS LEFT A Control

Posted on 1999-01-16
8
157 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
  • 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
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

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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 …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

789 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