【问题标题】:Full screen C# Application全屏 C# 应用程序
【发布时间】:2010-11-12 19:49:20
【问题描述】:

如何在 Visual Studio Express 2010 中创建全屏 C# Windows 窗体应用程序?我试过this link,但它只显示http://pixpipeline.com/d/57a8554712e8.png

【问题讨论】:

标签: c# fullscreen


【解决方案1】:

不需要特殊的技巧。将 FormBorderStyle 属性设置为 None,将 WindowState 设置为 Maximized。

【讨论】:

  • 值得一提的是,隐藏任务栏不需要任何“特殊技巧”。 Windows 识别出像这样创建的窗口想要全屏显示,并将它们放在任务栏的顶部。
  • 除非有问题,如果您将任务栏设置设置为“始终位于顶部”,它会隐藏应用程序。如果我理解 OP 的要求,他希望窗口是真正的全屏...在所有内容之上并覆盖所有显示器空间。
  • 如何将任务栏设置为“始终在顶部”?我在 Windows 7 中找不到此选项...
  • 该功能已在 Windows 7 中删除,但在 Windows XP 中仍可在“任务栏和开始菜单属性”下使用。
【解决方案2】:

http://www.vesic.org/english/blog/winforms/full-screen-maximize/
示例:http://www.vesic.org/blog/upload/MaxWinForm.zip

/// <summary>
/// Selected Win AI Function Calls
/// </summary>

public class WinApi
{
    [DllImport("user32.dll", EntryPoint = "GetSystemMetrics")]
    public static extern int GetSystemMetrics(int which);

    [DllImport("user32.dll")]
    public static extern void
        SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter,
                     int X, int Y, int width, int height, uint flags);        

    private const int SM_CXSCREEN = 0;
    private const int SM_CYSCREEN = 1;
    private static IntPtr HWND_TOP = IntPtr.Zero;
    private const int SWP_SHOWWINDOW = 64; // 0x0040

    public static int ScreenX
    {
        get { return GetSystemMetrics(SM_CXSCREEN);}
    }

    public static int ScreenY
    {
        get { return GetSystemMetrics(SM_CYSCREEN);}
    }

    public static void SetWinFullScreen(IntPtr hwnd)
    {
        SetWindowPos(hwnd, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW);
    }
}

/// <summary>
/// Class used to preserve / restore state of the form
/// </summary>
public class FormState
{
    private FormWindowState winState;
    private FormBorderStyle brdStyle;
    private bool topMost;
    private Rectangle bounds;

    private bool IsMaximized = false;

    public void Maximize(Form targetForm)
    {
        if (!IsMaximized)
        {
            IsMaximized = true;
            Save(targetForm);
            targetForm.WindowState = FormWindowState.Maximized;
            targetForm.FormBorderStyle = FormBorderStyle.None;
            targetForm.TopMost = true;
            WinApi.SetWinFullScreen(targetForm.Handle);
        }
    }

    public void Save(Form targetForm)
    {
        winState = targetForm.WindowState;
        brdStyle = targetForm.FormBorderStyle;
        topMost = targetForm.TopMost;
        bounds = targetForm.Bounds;
    }

    public void Restore(Form targetForm)
    {
        targetForm.WindowState = winState;
        targetForm.FormBorderStyle = brdStyle;
        targetForm.TopMost = topMost;
        targetForm.Bounds = bounds;
        IsMaximized = false;
    }
}

【讨论】:

  • 大概是因为您永远不希望全屏应用程序始终位于顶部...
【解决方案3】:

Kiosk mode 是您要用于搜索的词。

form.MaximizeBox = false;
form.MinimizeBox = false;
form.TopMost = true;
form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
form.WindowState = System.Windows.Forms.FormWindowState.Maximized;

【讨论】:

  • 当“BorderStyle”设置为“无”时,无需禁用最大化和最小化框。当“BorderStyle”为“无”时,整个窗口标题被删除,包括最小化、最大化和关闭框。
【解决方案4】:

在表单的属性中将“窗口状态”设置为“最大化” (https://i.stack.imgur.com/UfCvY.jpg)

【讨论】:

    【解决方案5】:

    要制作全屏应用程序,您必须执行以下操作...

    this.FormBorderStyle = FormBorderStyle.None;
    this.WindowState = FormWindowState.Maximized;
    

    这是表单的名称。

    【讨论】:

      猜你喜欢
      • 2010-10-10
      • 1970-01-01
      • 1970-01-01
      • 2012-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-13
      相关资源
      最近更新 更多