我正在創建一個程序,我要在窗口的右下角附近放置一個按鈕。我使用GetClientRect獲取窗口的頂部,底部,左側和右側。頂部和左側工作正常,但底部和右側不工作。這是我的代碼:在GetClientRect rect.bottom矩形不正確
WNDCLASSEX Program;
/*Class declaration*/
hWndMain = CreateWindowEx (WS_EX_APPWINDOW,
"Program",
"Program",
WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX,
GetSystemMetrics(SM_CXSCREEN)/2-210,
GetSystemMetrics(SM_CYSCREEN)/2-135,
420,270,
HWND_DESKTOP,
NULL,hInstance,NULL);
//Window Procedure
WM_CREATE:
{
RECT MaxSize;
GetClientRect(hWndMain,&MaxSize);
/*Menu declaration using CreateMenu, AppendMenu etc*/
HWND hCalculate = CreateWindowEx(0,WC_BUTTON,
"Calculate",
WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_DEFPUSHBUTTON | 0x00000001,
MaxSize.right-156,MaxSize.bottom-51,140,30,
hWnd,(HMENU)IDC_BUTTON1,
GetModuleHandle(NULL), 0);
}
在編譯代碼並運行程序後,我無法看到按鈕。請幫忙。
什麼「不起作用」?調用GetCLientRect函數後,MaxSize的值是多少? – 2012-01-31 05:34:20