C# 如何隐藏任务栏并让程序使用可用空间
我想隐藏任务栏并打开任何程序,使用任务栏所在的新空间。我试着使用这个类。 使用制度; 使用System.Runtime.InteropServicesC# 如何隐藏任务栏并让程序使用可用空间,c#,windows,taskbar,C#,Windows,Taskbar,我想隐藏任务栏并打开任何程序,使用任务栏所在的新空间。我试着使用这个类。 使用制度; 使用System.Runtime.InteropServices public class Taskbar { [DllImport("user32.dll")] private static extern int FindWindow(string className, string windowText); [DllImport("user32.dll")] private
public class Taskbar
{
[DllImport("user32.dll")]
private static extern int FindWindow(string className, string windowText);
[DllImport("user32.dll")]
private static extern int ShowWindow(int hwnd, int command);
[DllImport("user32.dll")]
public static extern int FindWindowEx(int parentHandle, int childAfter, string className, int windowTitle);
[DllImport("user32.dll")]
private static extern int GetDesktopWindow();
private const int SW_HIDE = 0;
private const int SW_SHOW = 1;
protected static int Handle
{
get
{
return FindWindow("Shell_TrayWnd", "");
}
}
protected static int HandleOfStartButton
{
get
{
int handleOfDesktop = GetDesktopWindow();
int handleOfStartButton = FindWindowEx(handleOfDesktop, 0, "button", 0);
return handleOfStartButton;
}
}
private Taskbar()
{
// hide ctor
}
public static void Show()
{
ShowWindow(Handle, SW_SHOW);
ShowWindow(HandleOfStartButton, SW_SHOW);
}
public static void Hide()
{
ShowWindow(Handle, SW_HIDE);
ShowWindow(HandleOfStartButton, SW_HIDE);
}
}
然后我调用了
Taskbar.Hide()
,但是程序没有使用新的空间。右键单击任务栏->任务栏设置->自动隐藏任务栏?您应该使用。正如您在文档中看到的,hWnd参数必须设置为hWnd\u BROADCAST
。此消息将发送到所有顶级窗口。系统参数更改通知应该是SPI_GETWORKAREA=0x0030
。有人能举个例子吗?我一直在试图弄清楚这一点,但p-invoke是一项棘手且不安全的业务。