-
Fixed window size
Searched MSDN for WS and CS styles.. did google search for window styles.. did a board search...
I can't seem to find a style that will create a window that cannot be resized..
I would like to create a window of fixed length and width for a calculator program.. this is how my parent window is initialized:
Code:
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH)(COLOR_MENU);
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"calculator", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
207, /* The programs width */
333, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
I would like to add a style with one of the blue highlighted portions of the code that would disable resizing of the parent window if this is possible.
any suggestions..?
-
I think that there's no style for that. you should check the WM_SIZE message and use the 'SetWindowPos' with the handler of the main window to resize, reposition, visibility, etc (search for that funciotn for more). just set a global window_width and height (207 and 333) and use them to create the window and then for reset it when size change.
Niara
-
>>I would like to add a style ...that would disable resizing of the parent window<<
Make sure your window doesn't have the WS_THICKFRAME window style (WS_OVERLAPPEDWINDOW includes that style).
If you still want all of the other styles associated with WS_OVERLAPPEDWINDOW then replace that parameter of your CreateWindowEx call with:
Code:
WS_OVERLAPPEDWINDOW&~WS_THICKFRAME
- or just OR the styles as you see fit.
If you need to control window dimensions at runtime then handle WM_GETMINMAXINFO messages; search this board for examples of its use.
-
There's many ways to do what you want. The following is one of the ways I usually did it:
Code:
case WM_GETMINMAXINFO :
((MINMAXINFO*)lParam)->ptMinTrackSize.x = XSIZE_WANTED;
((MINMAXINFO*)lParam)->ptMinTrackSize.y = YSIZE_WANTED;
return 0;
You now have a fixed constant size and you didn't need to change the windows border look [smile].
xeddiex.
-
When I want to disable resizing I usually start with WS_DLGFRAME instead of WS_OVERLAPPEDWINDOW and build it up from there.
For example: WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
Now that might not be quite the 'look' you want for your calculator but you can swap other style options in or out and it gives you one more possible approach to the problem.
Regards,
Brian
-
Hellow;
Code:
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"calculator", /* Title Text */
WS_CAPTION|WS_SYSMENU|WS_VISIBLE|WS_MINIMIZEBOX, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
207, /* The programs width */
333, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
Bye