)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to display full screen WinForms MetroForm like the Windows Application?

Platform: WinForms |
Control: MetroForm |
Published Date: May 11, 2015 |
Last Revised Date: January 6, 2020

Display full screen MetroForm

The MetroForm bounds have been handled in the NativeMethods class by excluding the system taskbar bounds. So, it is possible to override the NativeMethods class functionality and the MetroForm bounds can be set to full screen by overriding this class. The following code example demonstrates the same.

C#

using System.Runtime.InteropServices;
using Syncfusion.Windows.Forms;
//Sets the Form border style.
this.FormBorderStyle = FormBorderStyle.None;
//Gets the FullScreen.
WinApi.SetWinFullScreen(this.Handle);
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; // 0×0040
    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);
    }
}

 

VB

Imports System.Runtime.InteropServices
Imports Syncfusion.Windows.Forms
'Sets the Form border style.
Me.FormBorderStyle = FormBorderStyle.None
'Gets the FullScreen.
WinApi.SetWinFullScreen(Me.Handle)
Public Class WinApi
     <DllImport("user32.dll", EntryPoint := "GetSystemMetrics")> _
     Public Shared Function GetSystemMetrics(ByVal which As Integer) As Integer
     End Function
     <DllImport("user32.dll")> _
     Public Shared Sub SetWindowPos(ByVal hwnd As IntPtr, ByVal hwndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal flags As UInteger)
     End Sub
     Private Const SM_CXSCREEN As Integer = 0
     Private Const SM_CYSCREEN As Integer = 1
     Private Shared HWND_TOP As IntPtr = IntPtr.Zero
     Private Const SWP_SHOWWINDOW As Integer = 64 ' 0×0040
     Public Shared ReadOnly Property ScreenX() As Integer
         Get
              Return GetSystemMetrics(SM_CXSCREEN)
         End Get
     End Property
     Public Shared ReadOnly Property ScreenY() As Integer
         Get
    Return GetSystemMetrics(SM_CYSCREEN)
         End Get
     End Property
     Public Shared Sub SetWinFullScreen(ByVal hwnd As IntPtr)
         SetWindowPos(hwnd, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW)
     End Sub
End Class

Samples:

C#: http://www.syncfusion.com/downloads/support/directtrac/136015/MetroFormFullScreen-1949269231.zip

VB: http://www.syncfusion.com/downloads/support/directtrac/137686/MetroFormFullScreen_VB-988095194.zip

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon