码迷,mamicode.com
首页 > Windows程序 > 详细

wince隐藏任务栏

时间:2015-01-08 22:39:38      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:

前段时间做了一个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); } }

 

wince隐藏任务栏

标签:

原文地址:http://www.cnblogs.com/Mo-MaTure/p/4211908.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!