Reputation: 732
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
Upvotes: 1
Views: 2651
Reputation: 1146
I think you search WM_SIZE MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ms632646.aspx
Upvotes: 1