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); } }
  • 相关阅读:
    SQL随机排序
    根据经纬度获取所在城市的相关信息以及根据地点城市获取经纬度
    百度收集自动推送脚本——python版
    采集(未测试)
    网页代码测试工具(很有用)
    微信红包源码2020年最新版(完整测试版)
    mvc返回多个结果集,返回多个视图
    计算工龄(mssql标量值函数)
    YZMCMS发布问题以及解决方法
    用输出的方式向页面和js增加引入
  • 原文地址:https://www.cnblogs.com/Mo-MaTure/p/4211908.html
Copyright © 2011-2022 走看看