I write in win32 api c++, and use mingw. I would like to resize a button when the main window is resized at runtime. Here is my code:
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
}
So I would like to resize the BUTTON at runtime. How can I do this? thanks
我认为您搜索WM_SIZE MSDN: http : //msdn.microsoft.com/zh-cn/library/windows/desktop/ms632646.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.