为何计算出的客户区的大小总是差点儿?
我在主窗口中显示一图片,要客户区的大小正好与图片一样,但计算出来的大小总是小点儿了,代码如下:
hBackGround=LoadBitmap(hInstance,"BACKMAP");
//计算标题栏和边框的宽度和高度
int nBorderWeight = GetSystemMetrics(SM_CXBORDER);
int nBorderHeight = GetSystemMetrics(SM_CYBORDER);
int captionHeight = GetSystemMetrics(SM_CYCAPTION);
BITMAP bmp;
GetObject(hBackGround,sizeof(BITMAP),&bmp);//得到的位图大小对
WNDCLASSEX wcex;
...
wcex.lpszMenuName=NULL;
...
wcex.style=CS_HREDRAW|CS_VREDRAW;
if(!RegisterClassEx(&wcex))
return false;
HWND hWnd=CreateWindow(szClassName,
szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
bmp.bmWidth+nBorderWeight*2, //算的不对??????
bmp.bmHeight+captionHeight+nBorderHeight*2,//算的不对??????
NULL,
NULL,
hInstance,
NULL);
if(!hWnd)
return 0;
ShowWindow(hWnd,nShowCmd);
UpdateWindow(hWnd);
MSG message;
while(GetMessage(&message,NULL,NULL,NULL) )
{
TranslateMessage(&message);
DispatchMessage(&message);
}
return message.wParam;
请问是不是少计算了某部分