我用win32 api c++编写,并使用mingw。当主窗口在运行时调整大小时,我想调整按钮的大小。这是我的代码:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// BLA BLA BLA
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
szClassName,
"Main Window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
800, // width
1000, // height
HWND_DESKTOP,
NULL,
hInstance,
NULL
);
// BLA BLA BLA
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_CREATE:
{
RECT rect;
GetClientRect(hwnd, &rect);
int width = rect.right - rect.left;
width = width-20;
HWND button = CreateWindowEx(BS_PUSHBUTTON, "BUTTON", "grafikon",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
10, 10, width, 25,
hwnd,
(HMENU)ID_BUTTON,
GetModuleHandle(NULL),
0);
// BLA BLA BLA
}
所以我想在运行时调整 BUTTON 的大小。我怎样才能做到这一点?谢谢