1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| 'Il faut insérer trois bouttons:
'button1 -> fermer l'application
'button2 -> réduire la fenetre
'button3 -> passer en plein écran
Public Class Form1
Public Declare Function SetWindowPos Lib "user32.dll" Alias "SetWindowPos" (ByVal hWnd As IntPtr, ByVal hWndIntertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As Integer) As Boolean
Private Declare Function GetSystemMetrics Lib "user32.dll" Alias "GetSystemMetrics" (ByVal Which As Integer) As Integer
Private Const SM_CXSCREEN As Integer = 0
Private Const SM_CYSCREEN As Integer = 1
Public Shared HWND_TOP As IntPtr = IntPtr.Zero
Public Const SWP_SHOWWINDOW As Integer = 64
Public ReadOnly Property ScreenX() As Integer
Get
Return GetSystemMetrics(SM_CXSCREEN)
End Get
End Property
Public ReadOnly Property ScreenY() As Integer
Get
Return GetSystemMetrics(SM_CYSCREEN)
End Get
End Property
Public Sub FullScreen(ByVal frm As Form, ByVal boolTopOptional As Boolean)
frm.WindowState = FormWindowState.Maximized
frm.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.TopMost = boolTopOptional
SetWindowPos(frm.Handle, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Application.Exit()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
FullScreen(Me, True)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TopMost = False
WindowState = FormWindowState.Normal
FormBorderStyle = Windows.Forms.FormBorderStyle.Sizable
End Sub
End Class
Public Class classFullScreen
Dim varScreen As Screen
Dim intWidth As Integer = Screen.PrimaryScreen.Bounds.Width
Dim intHeight As Integer = Screen.PrimaryScreen.Bounds.Height
Dim intTop As Integer = 0
Dim intLeft As Integer = 0
Dim intX As Integer = 0
Dim intY As Integer = 0
Public Function FullscreenTheForm(ByVal frm As Form)
frm.Top = intTop
frm.Left = intLeft
frm.Width = intWidth + 40
frm.Height = intHeight
frm.FormBorderStyle = FormBorderStyle.None
Return 0
End Function
End Class |
Partager