Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Console Application, hiding the title bar

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.

like image 450
asdrubael Avatar asked Oct 21 '09 09:10

asdrubael


2 Answers

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.

like image 182
Joey Avatar answered Oct 22 '22 15:10

Joey


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.

like image 22
Matt Joiner Avatar answered Oct 22 '22 16:10

Matt Joiner