Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Knowing when MOUSE HAS LEFT A Control

Posted on 1999-01-16
8
Medium Priority
?
189 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 40 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 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…

886 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