zoukankan      html  css  js  c++  java
  • wince隐藏任务栏

    前段时间做了一个wince项目。因为wince设备屏幕一般都比较小,所以经常隐藏任务栏来增大界面空间。在ce程序中调用下面的代码可以控制系统中任务栏的隐藏和显示

    下面是代码:

    /// <summary>
    /// 调用winceAPI
    /// </summary>
    public abstract class CommonApi
    {
        [DllImport("coredll.dll", EntryPoint = "FindWindow")]
        public static extern int FindWindow(string lpWindowName, string lpClassName);
        [DllImport("coredll.dll", EntryPoint = "ShowWindow")]
        public static extern bool ShowWindow(int hWnd, int nCmdShow);
        [DllImport("coredll.dll", EntryPoint = "SystemParametersInfo")]
        public static extern int SystemParametersInfo(
          int uAction,
          int uParam,
          ref Rectangle lpvParam,
          int fuWinIni
          );
        public const int SPI_SETWORKAREA = 47;
        public const int SPI_GETWORKAREA = 48;
    
        public const int SPIF_UPDATEINIFILE = 0x0001;
        public const int SPIF_SENDCHANGE = 0x0002;
    
        public const int SW_HIDE = 0;
        public const int SW_SHOWNORMAL = 1;
        public const int SW_SHOW = 5;
        public const int SW_SHOWNA = 8;
    }
    /// <summary>
    /// 隐藏开始方法
    /// </summary>
    private static Rectangle winRectangle = new Rectangle();
    public static bool SetFullScreen(bool fullscreen)
    {
        int Hwnd = 0;
        Hwnd = CommonApi.FindWindow("HHTaskBar", null);
        if (Hwnd == 0) return false;
        if (fullscreen)
        {
            CommonApi.ShowWindow(Hwnd, CommonApi.SW_HIDE);
            Rectangle rectFull = Screen.PrimaryScreen.Bounds;
            CommonApi.SystemParametersInfo(CommonApi.SPI_GETWORKAREA, 0, ref winRectangle, CommonApi.SPIF_UPDATEINIFILE);//get
            CommonApi.SystemParametersInfo(CommonApi.SPI_SETWORKAREA, 0, ref rectFull, CommonApi.SPIF_UPDATEINIFILE);//set
        }
        else
        {
            CommonApi.ShowWindow(Hwnd, CommonApi.SW_SHOW);
            CommonApi.SystemParametersInfo(CommonApi.SPI_SETWORKAREA, 0, ref winRectangle, CommonApi.SPIF_UPDATEINIFILE);
        }
        return true;
    }

    调用方法

    /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [MTAThread]
    static void Main()
    {   
    try {
    //隐藏开始 SetFullScreen(true);
    //显示开始 SetFullScreen(false); } catch (Exception ex) { Common.SetFullScreen(false); } }
  • 相关阅读:
    面试题:JS中map的陷阱
    C#中正则表达式进行忽略大小写的字符串替换
    C#窗体钉在桌面、置底、嵌入桌面的办法
    创建C#串口通信程序详解
    为类和函数代码自动添加版权注释信息
    C# 如何编辑文件的摘要信息
    C# GDI在控件上绘图
    泛型Dictionary的用法详解
    Winform 导出成Excel打印代码
    C#反射深入学习
  • 原文地址:https://www.cnblogs.com/Mo-MaTure/p/4211908.html
Copyright © 2011-2022 走看看