Quote Originally Posted by VbEndUser View Post
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.