Click to See Complete Forum and Search --> : How to create a Window and disable maximize/resize?


avrs
September 8th, 2009, 07:37 AM
I am using the CreateWindowEx to create my main program window, however every buttons on the caption and resizing is on. I wish to disable the maximize button and disable resizing but couldn't find anything online.
How can I do that?

srelu
September 8th, 2009, 06:59 PM
To remove completely the buttons you should remove the WS_MINIMIZEBOX and WS_MAXIMIZEBOX styles. Use the GetWindowLong and SetWindowLong functions.

avrs
September 9th, 2009, 12:48 AM
Ah I got it. I was using WS_OVERLAPPEDWINDOW instead of WS_OVERLAPPED so the buttons where all included by default. Thanks!

so is WS_POPUP the only way to remove the window border?

olivthill2
September 9th, 2009, 02:51 AM
I use CreateWindowEx(WS_EX_TOOLWINDOW, ...), for the creation of a window with just a thin title bar, good enough to move the window and slim enough to be pretty.

avrs
September 9th, 2009, 05:51 PM
I try to use:
SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU);
and doesn't seem to work, maybe I am doing something wrong?

motobizio
September 10th, 2009, 02:22 AM
Hello!

You can operate by 2 ways:

1. Disable voices in sysmenu:

// get the styles and properties of your window
DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE);
dwStyle &= ~(WS_MAXIMIZE|WS_SIZEBOX );
// set the window with style without titlebar and sizebox
SetWindowLong(hWnd, GWL_STYLE, dwStyle);


2. Delete those voices from your sysmenu

// hWnd is the handle of your main window
HMENU hMenu = GetSystemMenu(hWnd, FALSE);
DeleteMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND) ;
DeleteMenu(hMenu, SC_SIZE, MF_BYCOMMAND) ;


About displaying window without any border, I use following function:

CreateWindowEx(WS_EX_TOOLWINDOW|WS_EX_TOPMOST,szWindowClass, szTitle, WS_THICKFRAME|WS_POPUP,.......);


tell me if its works!