参考这个:
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private const int SWP_HIDEWINDOW = 0x80;
private const int SWP_SHOWWINDOW = 0x40;
private const int GW_CHILD = 5;
private const int SW_HIDE = 0;
private const int SW_SHOWNORMAL = 1;
[DllImport("user32.dll")]public static extern bool SetWindowPos(
int hWnd, // handle to window
int hWndInsertAfter, // placement-order handle
short X, // horizontal position
short Y, // vertical position
short cx, // width
short cy, // height
uint uFlags // window-positioning options
);
[DllImport("user32.dll")]public static extern int FindWindow(
string lpClassName, // class name
string lpWindowName // window name
);
[DllImport("user32.dll")]public static extern bool ShowWindow(
int hWnd, // handle to window
short nCmdShow // show state
);
[DllImport("user32.dll")]public static extern short ShowCursor(
bool bShow // cursor visibility
);
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{……}
#region Windows Form Designer generated code
……
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
int TaskBarHwnd;
TaskBarHwnd = FindWindow("Shell_traywnd", "");
if (button1.Text == "Hide Taskbar")
{
SetWindowPos(TaskBarHwnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW);
button1.Text = "Show Taskbar"; }
else
{
SetWindowPos(TaskBarHwnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW);
button1.Text = "Hide Taskbar";
}
}
private void button2_Click(object sender, System.EventArgs e)
{
int hWnd1;
hWnd1 = FindWindow("Progman", null);
if (button2.Text =="Hide Icons")
{
ShowWindow(hWnd1, SW_HIDE);
button2.Text ="Show Icons";
}
else
{
ShowWindow(hWnd1, SW_SHOWNORMAL);
button2.Text ="Hide Icons";
}
}
private void button3_Click(object sender, System.EventArgs e)
{
if (button3.Text =="Hide Cursor")
{
ShowCursor (false);
button3.Text ="Show Cursor";
}
else
{
ShowCursor (true);
button3.Text ="Hide Cursor";
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
button1.Text ="Hide Taskbar";
button2.Text ="Hide Icons";
button3.Text ="Hide Cursor";
}
}
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private const int SWP_HIDEWINDOW = 0x80;
private const int SWP_SHOWWINDOW = 0x40;
private const int GW_CHILD = 5;
private const int SW_HIDE = 0;
private const int SW_SHOWNORMAL = 1;
[DllImport("user32.dll")]public static extern bool SetWindowPos(
int hWnd, // handle to window
int hWndInsertAfter, // placement-order handle
short X, // horizontal position
short Y, // vertical position
short cx, // width
short cy, // height
uint uFlags // window-positioning options
);
[DllImport("user32.dll")]public static extern int FindWindow(
string lpClassName, // class name
string lpWindowName // window name
);
[DllImport("user32.dll")]public static extern bool ShowWindow(
int hWnd, // handle to window
short nCmdShow // show state
);
[DllImport("user32.dll")]public static extern short ShowCursor(
bool bShow // cursor visibility
);
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{……}
#region Windows Form Designer generated code
……
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
int TaskBarHwnd;
TaskBarHwnd = FindWindow("Shell_traywnd", "");
if (button1.Text == "Hide Taskbar")
{
SetWindowPos(TaskBarHwnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW);
button1.Text = "Show Taskbar"; }
else
{
SetWindowPos(TaskBarHwnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW);
button1.Text = "Hide Taskbar";
}
}
private void button2_Click(object sender, System.EventArgs e)
{
int hWnd1;
hWnd1 = FindWindow("Progman", null);
if (button2.Text =="Hide Icons")
{
ShowWindow(hWnd1, SW_HIDE);
button2.Text ="Show Icons";
}
else
{
ShowWindow(hWnd1, SW_SHOWNORMAL);
button2.Text ="Hide Icons";
}
}
private void button3_Click(object sender, System.EventArgs e)
{
if (button3.Text =="Hide Cursor")
{
ShowCursor (false);
button3.Text ="Show Cursor";
}
else
{
ShowCursor (true);
button3.Text ="Hide Cursor";
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
button1.Text ="Hide Taskbar";
button2.Text ="Hide Icons";
button3.Text ="Hide Cursor";
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货