|
-
Feb 8th, 2002, 03:34 PM
#1
Thread Starter
Stuck in the 80s
Resize: WS_SIZE? [Resolved]
I want to be able to resize my controls when the user resizes my form. I tried:
Code:
case WM_SIZE:
if ((HWND)lParam == hwnd)
{
MessageBox(hwnd, "You resized", "Resize", MB_OK | MB_ICONINFORMATION);
}
How do I get this to work?
Last edited by The Hobo; Feb 14th, 2002 at 03:35 PM.
-
Feb 8th, 2002, 10:52 PM
#2
Member
I think the best way would be to catch all the WM_SIZE messages that are sent to your main window. Then have a procedure that can make the proper sizing calculations based on the current size of the main window. These calculations are then applied to each control within the main window. Perhaps you can use enumeration to cycle through all the controls...
-
Feb 8th, 2002, 11:24 PM
#3
Thread Starter
Stuck in the 80s
I know what I have to do, but I don't know how. With my source in the previous post, the MessageBox doesn't fire when being resized. Why?
-
Feb 9th, 2002, 11:54 AM
#4
Member
Try this...
PHP Code:
#include <windows.h>
int fwSizeType=0;
int nWidth=0;
int nHeight=0;
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{ //Run through messages that window receives
switch (uMsg)
{
case WM_SIZE:
fwSizeType = wParam; // resizing flag
nWidth = LOWORD(lParam); // width of client area
nHeight = HIWORD(lParam); // height of client area
MessageBox(hWnd, "You resized", "Resize", MB_OK | MB_ICONINFORMATION);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return(DefWindowProc(hWnd, uMsg, wParam, lParam));
}
return(0L);
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow)
{ //Create the Window
MSG msg;
HWND hWnd;
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(GRAY_BRUSH-1);
wc.lpszMenuName = "TEST";
wc.lpszClassName = "TEST";
if (!RegisterClass(&wc))
return(0L);
hWnd = CreateWindow("TEST",
"TEST",
DS_CENTER | WS_OVERLAPPEDWINDOW,
10, 10, 750, 500,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return(msg.wParam);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|