|
在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); } |
|