Solved

Knowing when MOUSE HAS LEFT A Control

Posted on 1999-01-16
8
132 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:ljaques
Comment Utility
Thanks...i got it working in the EXACT way you were describing!
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 1

Expert Comment

by:Johnn
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now