GET_X_LPARAM | GET_Y_LPARAM

I am trying to get the x and y pos of the mouse.. It keeps giving me the
x position not the y.. What is going on? I had x and y set to lo/hi words..doesnt do anything

OutputDebugStringA(to_string(GET_Y_LPARAM(lParam)).c_str());


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
WORD xPos;
WORD yPos;
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HDC hdc;
	TCHAR greeting[] = _T("Hello, World!");
	RECT rect;
	GetClientRect(hWnd, &rect);
	
	switch (message)
	{
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);

		TextOut(hdc,
			5, 5,
			greeting, _tcslen(greeting));
	
		EndPaint(hWnd, &ps);
		break;
	
	case WM_CHAR:
		ShowWindow(hWnd,SW_MINIMIZE);
		break;
	case WM_MOUSEMOVE:

		OutputDebugStringA(to_string(GET_Y_LPARAM(lParam)).c_str());
	
		OutputDebugStringA("\n");
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
		break;
	}

	
Last edited on
I read an interesting piece about WM_MOUSEMOVE if you have multiple monitors.
Microsoft doesn't recommend to use the LOWORD and HIWORD macros in this case.

The funny part about that: from the 'windowsx.h':

#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))

Maybe this is the problem.

Topic archived. No new replies allowed.