★搜Asp.net★(www.soAsp.net),为专业技术文档网站。
包括Asp.net开发技术文档·C#开发技术文档·Access/SQL Server数据库开发技术文档·VB.NET开发技术文档。
还包括·项目实战经验总结·开发经验技巧总结·项目开发心得。


  
用C#实现显示和隐藏任务栏

在Windows操作系统中有自动隐藏和显示任务栏的功能,其实也可以在程序中调用Windows API 控制任务栏的显示和隐藏。

主要程序代码。

private const int SW_HIDE = 0;//API参数表示隐藏窗口
private const int SW_SHOW = 5;//API参数表示用当前的大小和位置显示窗口
public Form1()
{
    InitializeComponent();
}
[DllImportAttribute("user32.dll")]
private static extern int FindWindow(string ClassName, string WindowName);
[DllImport("user32.dll")]
private static extern int ShowWindow(int handle,int cmdShow);
private void button1_Click(object sender, EventArgs e)
{
    ShowWindow(FindWindow("Shell_TrayWnd", null), SW_SHOW);
}
private void button2_Click(object sender, EventArgs e)
{
    ShowWindow(FindWindow("Shell_TrayWnd", null), SW_HIDE);
}