Jump to content
  • Advertisement
Sign in to follow this  
Antonym

problem with WM_LBUTTONDOWN

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

For some reason no matter what key I press it seems to activate the WM_LBUTTONDOWN case. Any reason why this could be happening? Any way to fix it? Thanks
LRESULT CALLBACK application::WndProc(HWND hWnd, UINT message,
											   WPARAM wParam, LPARAM lParam)
{
    switch(message)
	{
	case WM_KEYDOWN:
		switch(wParam)
		{
		case VK_RETURN:
			onCommandKey(RETURN);
			break;
		case VK_ESCAPE:
			onCommandKey(ESCAPE);
			break;
		default:
			break;
		}
	case WM_LBUTTONDOWN:
		{
			input_.x = GET_X_LPARAM(lParam);
			input_.y = GET_Y_LPARAM(lParam);
			onCommandKey(LM_BUTTON);
		}break;
	case WM_MOUSEMOVE:
		{
			input_.x = GET_X_LPARAM(lParam);
			input_.y = GET_Y_LPARAM(lParam);
		}break;		
	default:
		break;
	}

    return DefWindowProc (hWnd, message, wParam, lParam);
}



Share this post


Link to post
Share on other sites
Advertisement
How embarrasing, thanks!

A second question, the position of my window seems to affect/offset the mouse coordinates I recieve from the window messages. How can I fix this?

Share this post


Link to post
Share on other sites
For both WM_LBUTTONDOWN and WM_MOUSEMOVE, the coordinate you receive in the lParam is relative to your window's client area, so the absolute position of your window on the desktop shouldn't be affecting them. Are you sure you're not doing something funky (ClientToScreen / ScreenToClient, maybe) with _input later on?

Share this post


Link to post
Share on other sites
You're right, I just noticed that it doesn't have to do with the window's position, it depends on how far the cursor is from the top of the window, the further to the bottom the more the offset occurs :S.

Share this post


Link to post
Share on other sites
Sounds like there's something iffy between setting the _input.y coordinate, and acting on it, i.e., rendering a cursor or displaying it on screen. Give code in that area a double-check.

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!