wince 隐藏、显示任务栏

18 篇文章 0 订阅
6 篇文章 0 订阅

 

  有时候需要将任务栏隐藏,封装了一个类。在窗口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); //隐藏任务栏
        }
    }
}

    

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值