Sign in to follow this  
Antonym

problem with WM_LBUTTONDOWN

Recommended Posts

Antonym    179
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
Antonym    179
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
mattd    1078
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
Antonym    179
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
mattd    1078
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this