I have a Windows console application written in C++ and want to hide/remove the complete title bar of the console window, including the close, min/max controls etc. I searched a lot but didn't found anything useful yet.
I inquire the console HWND with GetConsoleWindow and tried to change the console window style with SetWindowLong by removing the WS_CAPTION flag, but this seems to have no effect at all:
HWND hwnd = GetConsoleWindow();
LONG style = GetWindowLong(hwnd, GWL_STYLE);
style &= ~(WS_BORDER|WS_CAPTION|WS_THICKFRAME);
SetWindowLong(hwnd, GWL_STYLE, style);
SetWindowPos( hwnd, NULL, 0,0,0,0,
SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE
|SWP_FRAMECHANGED );
I also tried GetSystemMenu/RemoveMenu but this seems only to disable controls like the close button.
You can't. Generally the hWnd of a console window is not guaranteed to be suitable for all window handle operations as, for example, documented here.
You could try a complex solution involving hiding the console window (this is possible), and then setup a window (without the controls) that forwards appropriate events back and forth from the real console window. In particular GDI events to draw the console window contents in your fake console window, and interact with the scrollbar (which in turn adjusts the console...).
This solution is pretty far out, and quite technical.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With