|
|
下面的程序结果是 w:634 h:455
#include <windows.h>
#include <stdio.h>
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASS wc;
HWND hWnd;
RECT r;
char s[32];
int w = 640, h = 480;
DWORD style = WS_OVERLAPPED | WS_SYSMENU;
memset (&wc, 0, sizeof(wc));
wc.lpfnWndProc = DefWindowProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor (NULL,IDC_ARROW);
wc.lpszClassName = "TEST_WINDOW_CLASS";
RegisterClass (&wc);
r.left = 0;
r.top = 0;
r.right = w;
r.bottom = h;
AdjustWindowRect(&r, style, FALSE);
w = r.right;
h = r. bottom;
hWnd = CreateWindowEx( 0,
wc.lpszClassName, "test",
style,
0, 0, w, h,
NULL, NULL, hInstance, NULL);
ShowWindow(hWnd, SW_SHOW);
SetForegroundWindow(hWnd);
GetClientRect(hWnd, &r);
sprintf(s, "w:%d, h:%d", r.right, r.bottom);
MessageBox(hWnd, s, 0, 0);
DestroyWindow(hWnd);
return 0;
}
为什么不是w:640, h:480呢 |
|