[C#][WinForm]如何控制工作列

  • 12266
  • 0
  • C#
  • 2009-12-07

[C#][WinForm]如何控制工具列

MSDN網友問題,自己實作紀錄一下。

在參考如何以程式設計方式隱藏及取消隱藏在 Windows 工作列

馬上就可以達到該需求。

 

        [DllImport("user32.dll")]
        private static extern IntPtr FindWindow(String className, String windowText);
        [DllImport("user32.dll")]
        private static extern Int32 ShowWindow(IntPtr hwnd, Int32 command);
        private const Int32 HIDE = 0;
        private const Int32 SHOW = 1;

        private void button1_Click(Object sender, EventArgs e)
        {
            IntPtr TaskBar = FindWindow("Shell_TrayWnd", "");
            ShowWindow(TaskBar, SHOW);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            IntPtr TaskBar = FindWindow("Shell_TrayWnd", "");
            ShowWindow(TaskBar, HIDE);
        }

Hide TaskBar

 

image

Show TaskBar

image