C ++ console application hiding the title bar

I have a Windows console application written in C ++ and you want to hide / remove the full title bar of the console window, including close, min / max controls, etc. I searched a lot, but have not yet found anything useful.

I request the HWND console using GetConsoleWindow and try to change the console window style using SetWindowLong by removing the WS_CAPTION flag, but this does not seem to have any effect:

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 only disables the controls, such as the close button.

+6
c ++ winapi console
source share
4 answers

You can not. As a rule, the hWnd of the console window may not be suitable for all operations with window handles, for example, here .

+5
source share

You can try the complex solution of hiding the console window (this is possible), and then configure the window (without controls), which translates the corresponding events back and forth from the real console window. In particular, GDI events for drawing the contents of a console window in your fake console window and interacting with the scroll bar (which, in turn, sets up the console ...).

This solution is quite far and quite technical.

+2
source share

I think I will write / use two programs. One console program does the work, and the second a managed console window with the first. Most likely, there are already existing console programs, and some can be launched without a header? Or find an open source file and modify it.

0
source share

You can use SetWindowLongPtr(hWnd, GWL_STYLE, WS_POPUP); which will remove the header / header and borders.
Warning: This leads to some crashes that I don’t know how to fix (I think they are cached borders?), But at least it gives the effect you want.

0
source share

All Articles