This is not what i want.
The code able to detect when the mouse go inside the dialog client area.
But it seem to be don't know when it leave the client area.
It entering the dialog area and leave the client area at the same time(refer to the message above)
That is why i get the message above.
But the _TrackMouseEvent only will post the message WM_MOUSELEAVE when the mouse leave the
client area but it did not work that way. Why?

I have check the MSDN and found that the the default area of the mouse hover area just as the mouse click area.
That is 4 pixels. so i have try to adjust the area to the dialog client are with the code below:
But i'm still getting the same result.

I have search through the similar post in Codeguru but not luck, I did not found the solution there.
Can somebody help me.
Thanks.

October 28th, 2012, 10:46 AM

D_Drmmr

Re: _TrackMouseEvent not working

First, after more than 50 posts, you should know how to use code tags. Please edit your post and use them.
Second, it's not clear to me what you want to achieve.
Third, why are you using SetCapture and TrackMouseEvent at the same time? You should use either depending on the behavior that you want.

October 31st, 2012, 05:56 AM

VbEndUser

1 Attachment(s)

Re: _TrackMouseEvent not working

Dear D_Drmmr,

Thanks for pointing out my thread's problem.
I always want to post my code in the window just that i did not know the script.
There was no shortcut key or button.

Refer back to my question:
I not sure how to detect the mouse in and mouse leave in a control which attached to my dialogbox.
Please refer to my attachment.

I need to use Setcapture to detect my mouse position when it move over the control.
Of cause we can use control.RectInPt(mouse position) to track the mouse whether is in the control rect or not
If another window pop up, then i not able to to release the mouse using ReleaseCapture.

I will ReleaseCapture when user doubleclick on the control and at the same time another window will pop up.
Hope my question is clear.
Thanks.

October 31st, 2012, 11:09 AM

D_Drmmr

Re: _TrackMouseEvent not working

Quote:

Originally Posted by VbEndUser

I not sure how to detect the mouse in and mouse leave in a control which attached to my dialogbox.
Please refer to my attachment.

I need to use Setcapture to detect my mouse position when it move over the control.

You don't need to call SetCapture to detect when the mouse is inside our outside your control. When the mouse moves inside your control, you receive a WM_MOUSEMOVE message (i.e. your OnMouseMove function will be called). In that function you call TrackMouseEvent, such that you will receive a WM_MOUSELEAVE message whenever the mouse cursor leaves your control (you will not receive WM_MOUSEMOVE messages when the mouse cursor moves outside the control).

You should only use SetCapture and ReleaseCapture if you want to keep receiving WM_MOUSEMOVE messages when the mouse moves outside the control. E.g. you can call SetCapture when the user starts dragging inside your control and ReleaseCapture when the dragging ends.