How do I make a WinForms app go Full Screen

前端 未结 9 1504
你的背包
你的背包 2020-11-22 11:20

I have a WinForms app that I am trying to make full screen (somewhat like what VS does in full screen mode).

Currently I am setting FormBorderStyle to <

9条回答
  •  星月不相逢
    2020-11-22 12:15

    I recently made an Mediaplayer application and I used API-calls to make sure the taskbar was hidden when the program was running fullscreen and then restored the taskbar when the program was not in fullscreen or not had focus or was exited.

    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer
    
    Sub HideTrayBar()
        Try
    
    
            Dim tWnd As Integer = 0
            Dim bWnd As Integer = 0
            tWnd = FindWindow("Shell_TrayWnd", vbNullString)
            bWnd = FindWindowEx(tWnd, bWnd, "BUTTON", vbNullString)
            ShowWindow(tWnd, 0)
            ShowWindow(bWnd, 0)
        Catch ex As Exception
            'Error hiding the taskbar, do what you want here..
        End Try
    End Sub
    Sub ShowTraybar()
        Try
            Dim tWnd As Integer = 0
            Dim bWnd As Integer = 0
            tWnd = FindWindow("Shell_TrayWnd", vbNullString)
            bWnd = FindWindowEx(tWnd, bWnd, "BUTTON", vbNullString)
            ShowWindow(bWnd, 1)
            ShowWindow(tWnd, 1)
        Catch ex As Exception
        'Error showing the taskbar, do what you want here..     
                   End Try
    
    
    End Sub
    

提交回复
热议问题