none
Hide Task bar with Full screen (Application Loading) RRS feed

  • Question

  • Hi,

    I need to load my application in full screen mode without task bar. How can i do this. Please Help me.

    Thank you......


    RohanD


    • Edited by RAT_SL Tuesday, October 8, 2019 6:01 PM
    Tuesday, October 8, 2019 6:15 AM

Answers

  • Hello,

    Add this code module to your project and call FullScreen in form load.

    EDIT: I've tested this on both Windows 10 and Windows 7.

    Public Module WindowFormsExtensions
        Private Declare Function SetWindowPos Lib "user32.dll" _
            Alias "SetWindowPos" (hWnd As IntPtr,
                                  hWndInsertAfter As IntPtr,
                                  X As Integer,
                                  Y As Integer,
                                  cx As Integer,
                                  cy As Integer,
                                  uFlags As Integer) As Boolean
    
        Private HWND_TOP As IntPtr = IntPtr.Zero
        Private Const SWP_SHOWWINDOW As Integer = 64
    
        ''' <summary>
        ''' Place form into full screen mode
        ''' </summary>
        ''' <param name="sender">Form instance</param>
        ''' <param name="TaskBar">True to hide Windows TaskBar</param>
        ''' <remarks>
        ''' Showing this task bar may not work fully but that is not the
        ''' point here, the point is to cover the task bar with a option
        ''' to expose it is secondary.
        ''' </remarks>
        <Runtime.CompilerServices.Extension()>
        Public Sub FullScreen(sender As Form, Optional TaskBar As Boolean = True)
    
            sender.WindowState = FormWindowState.Maximized
            sender.FormBorderStyle = FormBorderStyle.None
            sender.TopMost = True
    
            If TaskBar Then
    
                SetWindowPos(sender.Handle, HWND_TOP, 0, 0,
                             Screen.PrimaryScreen.Bounds.Width,
                             Screen.PrimaryScreen.Bounds.Height,
                             SWP_SHOWWINDOW
                             )
    
            End If
    
        End Sub
        ''' <summary>
        ''' Restore to original size/position
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <remarks></remarks>
        <Runtime.CompilerServices.Extension()>
        Public Sub NormalMode(sender As Form)
            sender.WindowState = FormWindowState.Normal
            sender.FormBorderStyle = FormBorderStyle.FixedSingle
            sender.TopMost = True
        End Sub
    
    End Module


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Tuesday, October 8, 2019 9:56 AM
    Moderator

All replies

  • Hi,

    You can try my code as follows.

    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Me.FormBorderStyle = FormBorderStyle.None
            Me.WindowState = FormWindowState.Maximized
        End Sub
    End Class

    Hope it will be helpful.

    Best Regards,

    Julie


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 8, 2019 7:09 AM
    Moderator
  • Hi Rohan Danushka,

    Please try this code (VB.NET).
    Public Class Form1
    	' --- Constant
    	Private Const SW_SHOW As Integer = 5
    	Private Const SW_HIDE As Integer = 0
    	' --- User32.dll
    	Public Declare Auto Function FindWindow Lib "USER32.DLL" (
    			ByVal lpClassName As String,
    			ByVal lpWindowName As String) As IntPtr
    	Public Declare Auto Function ShowWindow Lib "USER32.DLL" (
    			ByVal hWnd As IntPtr, ByVal nCmdShow As IntPtr) As Boolean
    	' --- event form.SizeChanged
    	Private Sub Form1_SizeChanged(sender As Object, e As EventArgs) _
    			Handles MyBase.SizeChanged
    		' ---
    		Dim pHandle As IntPtr
    		Dim pHandle2 As IntPtr
    		' ---
    		pHandle = FindWindow("Shell_TrayWnd", vbNullString)
    		pHandle2 = FindWindow("Button", "Start")
    		' ---
    		If (Me.WindowState = FormWindowState.Maximized) Then
    			ShowWindow(pHandle, SW_HIDE)    ' -- hide Taskbar
    			ShowWindow(pHandle2, SW_HIDE)   ' -- hide [Start] button
    		Else
    			ShowWindow(pHandle, SW_SHOW)    ' -- show Taskbar
    			ShowWindow(pHandle2, SW_SHOW)   ' -- show [Start] button
    		End If
    	End Sub
    End Class
    When the size of Form is changed and its WindowsState is Maximized, Taskbar (and [Start] button) will be hidden.  But its space on monitor screen still remains.

    Regards,

    Ashidacchi -- https://ssl01.rocketnet.jp/hokusosha.com/default.html

    Tuesday, October 8, 2019 7:37 AM
  • Please try this code (VB.NET).
    			ShowWindow(pHandle, SW_HIDE)    ' -- hide Taskbar

     You should not do this : How do I cover the taskbar with a fullscreen window?
    Tuesday, October 8, 2019 8:16 AM
  • @Castorix31,

    I could run my code successfully in Windows 10 (physical machine)and Windows 7 (virtual machine). My code does not COVER the taskbar.


    Regards,

    Ashidacchi -- https://ssl01.rocketnet.jp/hokusosha.com/default.html

    Tuesday, October 8, 2019 8:54 AM
  • I could run my code successfully in Windows 10 (physical machine)and Windows 7 (virtual machine). My code does not COVER the taskbar.

    Read the part about :

    ShowWindow(hwndTaskbar, SW_HIDE)

    Tuesday, October 8, 2019 8:58 AM
  • @Castorix31,

    My previous post was unnecessary. 
    I suppose hiding the taskbar or not depends OP. 

    Regards,

    Ashidacchi -- https://ssl01.rocketnet.jp/hokusosha.com/default.html

    Tuesday, October 8, 2019 9:06 AM
  • Hello,

    Add this code module to your project and call FullScreen in form load.

    EDIT: I've tested this on both Windows 10 and Windows 7.

    Public Module WindowFormsExtensions
        Private Declare Function SetWindowPos Lib "user32.dll" _
            Alias "SetWindowPos" (hWnd As IntPtr,
                                  hWndInsertAfter As IntPtr,
                                  X As Integer,
                                  Y As Integer,
                                  cx As Integer,
                                  cy As Integer,
                                  uFlags As Integer) As Boolean
    
        Private HWND_TOP As IntPtr = IntPtr.Zero
        Private Const SWP_SHOWWINDOW As Integer = 64
    
        ''' <summary>
        ''' Place form into full screen mode
        ''' </summary>
        ''' <param name="sender">Form instance</param>
        ''' <param name="TaskBar">True to hide Windows TaskBar</param>
        ''' <remarks>
        ''' Showing this task bar may not work fully but that is not the
        ''' point here, the point is to cover the task bar with a option
        ''' to expose it is secondary.
        ''' </remarks>
        <Runtime.CompilerServices.Extension()>
        Public Sub FullScreen(sender As Form, Optional TaskBar As Boolean = True)
    
            sender.WindowState = FormWindowState.Maximized
            sender.FormBorderStyle = FormBorderStyle.None
            sender.TopMost = True
    
            If TaskBar Then
    
                SetWindowPos(sender.Handle, HWND_TOP, 0, 0,
                             Screen.PrimaryScreen.Bounds.Width,
                             Screen.PrimaryScreen.Bounds.Height,
                             SWP_SHOWWINDOW
                             )
    
            End If
    
        End Sub
        ''' <summary>
        ''' Restore to original size/position
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <remarks></remarks>
        <Runtime.CompilerServices.Extension()>
        Public Sub NormalMode(sender As Form)
            sender.WindowState = FormWindowState.Normal
            sender.FormBorderStyle = FormBorderStyle.FixedSingle
            sender.TopMost = True
        End Sub
    
    End Module


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Tuesday, October 8, 2019 9:56 AM
    Moderator
  • Thank you so much this code is working. but I have 1 warning. can you please check this.

    Warning CA1060 Move pinvokes to native methods class

    RohanD

    Tuesday, October 8, 2019 8:10 PM
  • Thank you so much this code is working. but I have 1 warning. can you please check this.

    Warning CA1060 Move pinvokes to native methods class

    RohanD

    Hello,

    There is zero issue with this warning in regards to this code while in other code using different API's there might be an issue but not in this code. But if this truly bothers you we would need to place the current code in a code module into a class, create the class and call the method while in the new class which use to be the code module would need then to create an instance of the NativeMethod class. This is because the current code is in a code module where extension methods belong while in C# the counter part is a static class and if we were dealing with C# the current code would need to move out of the static class.

    Bottom line is the code works just fine, ignore the warning.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, October 8, 2019 8:56 PM
    Moderator
  • Ok.. Thank you so much 

    RohanD

    Wednesday, October 9, 2019 5:17 AM