我只是想在最上面的全屏窗口顶部显示 Windows 任务栏。
我试过这个但我没有工作:
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowA(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern bool UpdateWindow(IntPtr hWnd);
public static void ShowTaskbar()
{
var Handle = FindWindowA("Shell_TrayWnd", null);
SetFocus(Handle);
UpdateWindow(Handle);
ShowWindow(Handle, 5);
}
我正在处理的事情非常具体,我创建的窗口必须覆盖所有显示器并位于除任务栏之外的所有窗口之上,所以我编写了以下代码:
public static void SetWindowAsOverlay()
{
Margins margins = new Margins { cxLeftWidth = -1}
SetWindowLong(CurrenthWnd, GWL_EXSTYLE, WS_EX_LAYERED | WS_EX_TRANSPARENT);
DwmExtendFrameIntoClientArea(CurrenthWnd, ref margins);
SetWindowPos(CurrenthWnd, HWND_TOPMOST, 0, 0, 0, 0, 0);
}