为什么这个c#函数没有正确隐藏标题栏?

问题描述 投票:0回答:1

该功能不会隐藏标题栏,而是仅隐藏最小化/最大化/关闭按钮。

我正在尝试使窗口完全无边框,这样我就可以制作一个应用程序,使在窗口模式下运行的游戏周围的所有内容变暗。

这些是常数:

const uint SWP_FRAMECHANGED = 0x0020;
const uint SWP_NOMOVE = 0x0002;
const uint SWP_NOSIZE = 0x0001;
const uint SWP_NOZORDER = 0x0004;

const int GWL_STYLE = -16;
const long WS_BORDER = 0x00800000L;
const long WS_CAPTION = 0x00C00000L;
const long WS_SYSMENU = 0x00080000L;

这是功能:

IntPtr hWnd = CurrentWindowID;

long currentStyle = GetWindowLong(hWnd, GWL_STYLE);

// Remove WS_BORDER, WS_CAPTION, and WS_SYSMENU styles to make the window borderless
long newStyle = currentStyle & ~(WS_BORDER | WS_CAPTION | WS_SYSMENU);

// Update the window style
SetWindowLong(hWnd, GWL_STYLE, newStyle);

// Update the window position and size to apply the style change
SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
c# windows titlebar borderless
1个回答
0
投票

好的,上面的代码可以工作,但不适用于我用来测试的 Windows 资源管理器。

© www.soinside.com 2019 - 2024. All rights reserved.