WM_MOUSELEAVE message

I'm writing an ActiveX control. I must know when the mouse leaves the area of my control. I wrote the following function to track this event:

void CNMButtonCtrl::SetMouseTrackEvent()
{
      TRACKMOUSEEVENT tme;
      tme.cbSize = sizeof(tme);
      tme.dwFlags = TME_LEAVE;
      tme.hwndTrack = m_hWnd;
      _TrackMouseEvent(&tme);
}

I get the WM_MOUSELEAVE event in the following function:

LRESULT CNMButtonCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
      if(message == WM_MOUSELEAVE)
      {
            AfxMessageBox ("WM_MOUSELEAVE", MB_OK, 0);
      }
      
      return COleControl::WindowProc(message, wParam, lParam);
}

Also, i have the following function using which i tell Windows that i want to listen to this event:

void CNMButtonCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
      SetMouseTrackEvent();
      
      COleControl::OnMouseMove(nFlags, point);
}

So i'm notified when i receive the WM_MOUSELEAVE event.

My problem is:
I do not receive this event when the user moves the mouse with the LEFT BUTTON PRESSED.

How to solve this problem?
LVL 2
MindoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MichaelSCommented:
You can do it wery easy, may be not very professional. Register some timer and each time you receive message from it just check where mouse is with GetCursorPos().

Probably some app use SetCapture or whatever on left mouse button click.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MindoAuthor Commented:
So you suggest me not to use the _TrackMouseEvent() API and use the timer?
0
MichaelSCommented:
I see two ways here, one is trying to figure out why your approach doesn't works and another is to use different way. It'a up to you what to use.
0
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

RONSLOWCommented:
I have not seen this behaviour with my own controls (although they are not ActiveX controls).  _TrackMouseEvent works fine regardless of mouse buttons

It could be that someone else is getting hold of these messages and treating it as a drag.

What happens when you get a left-button down event?  Does it do something like capture the mouse and do a message loop?


0
MindoAuthor Commented:
When i get the WM_LBUTTONDOWN, i don't havea message loop nor do i capture the mouse. I don't know why don't i get the WM_MOUSELEAVE event.
0
RONSLOWCommented:
Does it fail when
1) you already have the mouse button down when OUTSIDE the control, keeping the mouse button down move over the control and out again

2) you are inside the control with mouse button up, then press and hold the mouse button and move out (ie. a bit like you are trying to drag the control).

If 2) only, then I think some bit of code is thinking you are trying to drag the window (noone called DragDetect are they?).  If both, then ... buggered if I know.
0
MindoAuthor Commented:
Yes, my case is the 2). I think i'll use the timer to detect MouseLeave and MouseEnter events. I've found an example of how to do this.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.