Jump to content
  • Advertisement
Sign in to follow this  
toan1982

Get position of mouse when mouse move on control

This topic is 4618 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!!!

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!