简体   繁体   English

如何仅删除 C 程序中的控制台标题?

[英]How to remove only the title of console in a C program?

How can I remove only the title of the console in C or C++?如何仅删除 C 或 C++ 中的控制台标题?

Remove that:删除:

图片

HWND hwnd = GetConsoleWindow(); 
DWORD style = GetWindowLong(hwnd, GWL_STYLE);
style &= ~WS_THICKFRAME;
SetWindowLong(hwnd, GWL_STYLE, style); 

I tried that, but it doesn't work.我试过了,但它不起作用。

You can use the function SetWindowText , like this:您可以使用 function SetWindowText ,如下所示:

SetWindowText( GetConsoleWindow(), TEXT("") );

This will set the title of the window to an empty string.这会将 window 的标题设置为空字符串。

If you want to remove the entire title bar, then you can use the following code:如果要删除整个标题栏,则可以使用以下代码:

DWORD style = GetWindowLong( GetConsoleWindow(), GWL_STYLE );
style &= ~WS_CAPTION;
SetWindowLong( GetConsoleWindow(), GWL_STYLE, style );

However, moving the window will be a lot harder without a title bar.但是,如果没有标题栏,移动 window 会困难得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM