I want to make my console app window to be like this:
A minimal style in other words...
With no possibility to resize the window and with only the Close button
How should I proceed?
I want to make my console app window to be like this:
A minimal style in other words...
With no possibility to resize the window and with only the Close button
How should I proceed?
1) #include <windows.h> at the top of your program...
2) If you are making your own window you manage styles by options in the CreateWindow() or your dialog resources.
CreateWindow Function (Windows)
2) if you need to change it on the fly you would use GetConsoleWindow() then SetWindowLong() and SetConsoleTitle()
GetConsoleWindow Function (Windows)
SetWindowLong Function (Windows)
SetConsoleTitle Function (Windows)
Last edited by CommonTater; 04-27-2011 at 04:03 PM.
Note that you can't do this on XP, since the console window is owned by a system process which denies you access to fiddling the window styles. On Vista/7, use GetWindowLongPtr(hwnd, GWL_STYLE), mask off the minimize, maximize, and thickframe styles, and set the result with SetWindowLongPtr. Then you'll need to force the window to update with SetWindowPos(..., SWP_FRAMECHANGED)
Last edited by adeyblue; 04-27-2011 at 04:10 PM.
I did it, thanks!
But, I had to modify the screen buffers, because horizontal and vertical scroll bars were appearing on the window. I just adjusted the screen buffers and ok.
But I still have a little problem that I think it cannot be solved with screen buffers...
When the app starts, the window is completely ok, adjusted... if I try to enlarge it, nothing will happen, BUT if I try to resize it to a smaller size, it will. That's the problem... I don't want the window to be resizeable.
The console is limited to the maximum width of chars in its properties. This is restricted to modification with the mouse and explains why the window will resize to a certain extent then stop. However you may be able to subclass the console and intercept its WM_SIZE messages either by throwing them away or resetting its size every time the user attempts to modify it.
Gosh, isn't there an easier way to block resizing instead of capturing window events?
Msdn search, 12 seconds -- > Window Styles (Windows)
Use SetWindowLong() to reset the style bits to one that does not allow resizing ... for example... WS_DLGFRAME | WS_CAPTION
I used it with GWL_EXSTYLE, WS_EX_TOOLWINDOW and it is the same style as my attachment... but it is still resizeable...
I tested other conbinations and values instead of WS_EX_TOOLWINDOW, but nothing works.
I thought setting it as a tool box would block its resizing, but no, and that's the problem.
Use GWL_STYLE ... you want the primary window styles not the extended ones.