Jump to content
  • Advertisement
Sign in to follow this  
Halsafar

Adjust GetCursorPos for GameWindow

This topic is 4887 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

I'm using GetCursorPos to get the pos of the cursor to determine which menu item should be highlighted. Simple box collision. Works fine in fullscreen mode no problems at all. In windowed mode the position of the quads and the mouse no longer match (obviously I guess...) Would I simply want to add the x,y (top,left) of the window to the cursor pos?

Share this post


Link to post
Share on other sites
Advertisement
Wouldn't you want to subtract the top left coordinate? Also remember to get the top left of the client area, not just your window. The title bar is large enough that not taking it into account will throw everything off a lot. Also, if you are scaling everything in the window once you go into Windowed mode, you will have to take that into account to.

Share this post


Link to post
Share on other sites
Use ScreenToClient to get the client mouse coordinates from the screen coordinates you get from GetCursorPos.

This works both in fullscreen and windowed mode.

POINT pt;

GetCursorPos( &pt );
ScreenToClient( m_hWnd, &pt );

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!