Get position of mouse when mouse move on control

Started by
0 comments, last by Omega147 18 years ago
Hi all member on this forum, I have asking and hope you will help me now... Using VC++6, i create a dialog and a control(picture is example) on this dialog. i'd like to know how to calculate the position of mouse when mouse move around on the control, and if mouse at the top and left of the control then position of mouse i get are (0,0). And sure the position of mouse is not affect to position that the dialog appear on desktop. If you know anything(functions in MFC/logic) to solve this please share with me.... Thanks for your help!!!
Advertisement
Look into the WM_MOUSEMOVE message, or for MFC, CWnd::OnMouseMove().

And yes, (0, 0) is the top-left corner of the control, however, you have to be careful of absolute coordinates and client coordinates of a window. Absolute coordinates use the window's border and caption (basically the entire window as it appears on the desktop) when calculating mouse position, while client coordinates are only positions within the window's paint area (border & caption excluded).

This topic is closed to new replies.

Advertisement