Solved

Knowing when MOUSE HAS LEFT A Control

Posted on 1999-01-16
8
164 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

749 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