hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
0, 0, 1280, 720, NULL, NULL, hInstance, NULL);
创建窗口时写了1280*720 ,实际上在接收
case WM_SIZE:
{
float aa = LOWORD(lParam); 这个 aa = 1265
float bb = HIWORD(lParam); 这个bb == 675
break;
}
根本不是自己想的,这样会出问题,实际创建的小于我想要的。如何解决
------解决思路----------------------
那是因为你创建的是WS_OVERLAPPEDWINDOW风格带边框和标题栏的窗口啊
这种情况下,WM_SIZE消息中的cx和cy只是客户区的宽度和高度,你可以进行下面两项测试,分别看看rtWindow和rtClient里面的相关值:
测试一:
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
0, 0, 1280, 720, NULL, NULL, hInstance, NULL);
//*********************************************************************
DWORD aa(0),bb(0);
RECT rtWindow = {0},rtClient={0};
//......
//......
case WM_SIZE:
aa = LOWORD(lParam);
bb = HIWORD(lParam);
::GetWindowRect(hWnd,&rtWindow);
::GetClientRect(hWnd,&rtClient);
return DefWindowProc(hWnd, message, wParam, lParam);
//.....
//....
测试二:
hWnd = CreateWindow(szWindowClass, szTitle, WS_CLIPCHILDREN
------解决思路----------------------
WS_CLIPSIBLINGS
------解决思路----------------------
WS_POPUP,
0, 0, 1280, 720, NULL, NULL, hInstance, NULL);
//*********************************************************************
DWORD aa(0),bb(0);
RECT rtWindow = {0},rtClient={0};
//......
//......
case WM_SIZE:
aa = LOWORD(lParam);
bb = HIWORD(lParam);
::GetWindowRect(hWnd,&rtWindow);
::GetClientRect(hWnd,&rtClient);
return DefWindowProc(hWnd, message, wParam, lParam);
//.....
//....