how to add a minimize button and maximize button on a dialog?
-
the following is my doing: in precreatewindow() cs.style|=MINIMIZEBOX; but doesnt work,somebody can give me some advice and explanination? thx
Are you creating the dialog at runtime, or toggling the min/max on and off buttons while the dialog is running?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
the following is my doing: in precreatewindow() cs.style|=MINIMIZEBOX; but doesnt work,somebody can give me some advice and explanination? thx
there are 2 better ways. if you are using a dialog resource then change the dialog settings with the resource editor (there is an option for min/max button). the other way is to change the window style run-time.
DWORD dwLong;
dwLong = GetWindowLong( hWnd, GWL_STYLE );
dwLong |= WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
SetWindowLong( hWnd, GWL_STYLE, dwLong );Don't try it, just do it! ;-)
-
there are 2 better ways. if you are using a dialog resource then change the dialog settings with the resource editor (there is an option for min/max button). the other way is to change the window style run-time.
DWORD dwLong;
dwLong = GetWindowLong( hWnd, GWL_STYLE );
dwLong |= WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
SetWindowLong( hWnd, GWL_STYLE, dwLong );Don't try it, just do it! ;-)
If in MFC, I think
ModifyStytle()
works the same way.ModifyStyle(0, WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
I have a little problem when making this style changes in run time tho. I placed it at the end of
OnInitDialog()
and the changes is made sucessfully. But at the first time the dialog appears, the MAXIMIZE and MINIMIZE icons (just the icons) are still on the menu bar, until the window is refreshed (e.g. switch to other dialog and switch back). Is this normal?