从Windows终端删除最小化按钮时,行为不一致
我正在使用Windows API从当前控制台窗口(Windows终端)禁用最小化按钮。
这是代码:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <windows.h>
bool disableMinimize ( HWND hwnd )
{
// use styles
DWORD style = GetWindowLong( hwnd, GWL_STYLE );
DWORD exStyle = GetWindowLong( hwnd, GWL_EXSTYLE );
// set the window styles
style &= ~WS_MINIMIZEBOX;
exStyle &= ~WS_EX_APPWINDOW;
// set the window styles
SetWindowLong( hwnd, GWL_STYLE, style );
SetWindowLong( hwnd, GWL_EXSTYLE, exStyle );
// return
return true;
}
int main() {
disableMinimize( GetConsoleWindow() );
}
期望的是,窗口上的( - )按钮被弄清楚或无法访问,但是当我在Windows终端运行时,这似乎不起作用。
我拥有的理论是,Windows终端强迫WS_Minimizebox是真实的,否则我会感到困惑。
我想念什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该终端绘制了自己的最小化按钮(在XAML中),并且根本不依赖Win32样式。如果您想从终端中删除最小化按钮,则可能应该在。
&lt;这是龙&gt;
从理论上讲,您可以通过禁用
showtabsintitlebar
。但是,知道getConsolewindow
不会为您提供实际终端HWND的处理 - 它只会使您与该选项卡相关联。我不能高度强调这一点 - 不要惹getConsolewindow
。这是一个不好的API,而且终端确实不太好。&lt;/
The Terminal draws its own minimize button (in XAML), and doesn't rely on the win32 styling at all for this. If you'd like to remove the minimize button from the Terminal, you should probably file a feature request on the Terminal repo.
<here be dragons>
Theoretically, you can get the win32 titlebar back by disabling
showTabsInTitlebar
. Know, however, thatGetConsoleWindow
isn't going to get you the handle of the actual Terminal HWND - it will only get you a hidden HWND associated with that tab. I cannot stress this highly enough - don't mess withGetConsoleWindow
. It's a bad API, and it really does NOT play nice with the Terminal.</????>