• 全屏窗体的完整方法(转)



    全屏窗体的完整方法:

    1.隐藏任务栏

    2.设置工作区域

    3.窗体最大化

    此方法通用wince/mobile/ppc,但api声明要修改为coredll.dll的引用。

    view plain
    bool fullscreen = false;
    Rectangle rect = new Rectangle();
    private void button4_Click(object sender, EventArgs e)
    {
    fullscreen = !fullscreen;//循环。点一次全屏,再点还原。
    SetFullScreen(fullscreen, ref rect);
    if (fullscreen)
    {
    this.WindowState = FormWindowState.Maximized;//全屏
    }
    else
    {
    this.WindowState = FormWindowState.Normal;//还原
    }
    }

    /// <summary>
    /// 设置全屏或这取消全屏
    /// </summary>
    /// <param name="fullscreen">true:全屏 false:恢复</param>
    /// <param name="rectOld">设置的时候,此参数返回原始尺寸,恢复时用此参数设置恢复</param>
    /// <returns>设置结果</returns>
    public static bool SetFullScreen(bool fullscreen, ref Rectangle rectOld)
    {
    int Hwnd = 0;
    Hwnd = FindWindow("Shell_TrayWnd", null);
    if (Hwnd == 0) return false;
    if (fullscreen)
    {
    ShowWindow(Hwnd, SW_HIDE);
    Rectangle rectFull = Screen.PrimaryScreen.Bounds;
    SystemParametersInfo(SPI_GETWORKAREA, 0, ref rectOld, SPIF_UPDATEINIFILE);//get
    SystemParametersInfo(SPI_SETWORKAREA, 0, ref rectFull, SPIF_UPDATEINIFILE);//set
    }
    else
    {
    ShowWindow(Hwnd, SW_SHOW);
    SystemParametersInfo(SPI_SETWORKAREA, 0, ref rectOld, SPIF_UPDATEINIFILE);
    }
    return true;
    }

    [DllImport("user32.dll", EntryPoint = "ShowWindow")]
    public static extern int ShowWindow(int hwnd, int nCmdShow);
    public const int SW_SHOW = 5; public const int SW_HIDE = 0;

    [DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
    private static extern int SystemParametersInfo(int uAction, int uParam, ref Rectangle lpvParam, int fuWinIni);
    public const int SPIF_UPDATEINIFILE = 0x1;
    public const int SPI_SETWORKAREA = 47;
    public const int SPI_GETWORKAREA = 48;

    [DllImport("user32.dll", EntryPoint = "FindWindow")]
    private static extern int FindWindow(string lpClassName, string lpWindowName);
    http://blog.csdn.net/wuyazhe/article/details/5728286

  • 相关阅读:
    HPC Linux
    Git安装使用
    Xshell和VirtualBox虚机CentOS7的连接
    Virtualbox中的Linux:未能加载虚拟光驱 VBoxsGuestAdditions.iso到虚拟电脑
    VirtualBox 主机与虚拟机互通
    在VirtualBox上安装CentOS7
    virtualbox 中的linux 共享文件
    【AT4434】[ARC103D] Distance Sums(构造)
    【洛谷3514】[POI2011] LIZ-Lollipop(构造)
    【LOJ6044】「雅礼集训 2017 Day8」共(prufer序列)
  • 原文地址:https://www.cnblogs.com/softwareking/p/2119108.html
Copyright © 2020-2023  润新知