wince 隐藏、显示任务栏

 有时候需要将任务栏隐藏,封装了一个类。在窗口load的时候,先调用hide(),窗口大小设置成屏幕大小就可以了。将windowstate设置成max不起作用,必须将窗口大小设置成屏幕大小

using System;
using System.Runtime.InteropServices;


namespace Austec.ToolCollection
{
    public class TaskBar
    {
        const uint SHFS_SHOWTASKBAR = 0x0001;
        const uint SHFS_HIDETASKBAR = 0x0002;
        const uint SHFS_SHOWSIPBUTTON = 0x0004;
        const uint SHFS_HIDESIPBUTTON = 0x0008;
        const uint SHFS_SHOWSTARTICON = 0x0010;
        const uint SHFS_HIDESTARTICON = 0x0020;
        const int SW_HIDE = 0;
        const int SW_SHOWNORMAL = 1;
        const int SW_SHOWMINIMIZED = 2;
        const int SW_SHOWMAXIMIZED = 3;
        const int SW_SHOWNOACTIVATE = 4;
        const int SW_RESTORE = 9;
        const int SW_SHOWDEFAULT = 10;


        [DllImport("aygshell.dll")]
        static extern uint SHFullScreen(IntPtr hwndRequester, uint dwState);

        [DllImport("coredll.dll")]
        private static extern IntPtr GetCapture();

        [DllImport("CoreDll")]
        private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        [DllImport("CoreDll")]
        private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);

        /// <summary> 
        /// 全屏显示 
        /// </summary> 
        /// <param name="objForm"></param> 
        private static void ShowFullScreen(System.Windows.Forms.Form objForm)
        {
            objForm.Capture = true;

            Hide();

            IntPtr hwnd = GetCapture();
            objForm.Capture = false;
            SHFullScreen(hwnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | SHFS_HIDESTARTICON);//全屏化窗口 
        }

        /// <summary> 
        /// 显示任务栏 
        /// </summary> 
        public static void Show()
        {
            IntPtr lpClassName = FindWindow("HHTaskBar", null);
            ShowWindow(lpClassName, SW_SHOWNORMAL); //显示任务栏 
        }

        /// <summary> 
        /// 隐藏任务栏 
        /// </summary> 
        public static void Hide()
        {
            IntPtr lpClassName = FindWindow("HHTaskBar", null);
            ShowWindow(lpClassName, SW_HIDE); //隐藏任务栏 
        }
    } 
}

    


你可能感兴趣的:(wince 隐藏、显示任务栏)