Ik had hier een keer gelezen over het maken van een fullscreen functie. Deze wil ik eigenlijk in een class doen zodat mijn code iets wat overzichtelijker word, alleen deze class kan ik niet maken omdat er 'Me' in gebruikt word. Hoe moet ik dat oplossen?
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
Private 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
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
Private Sub FullScreen()
Me.WindowState = FormWindowState.Maximized
Me.FormBorderStyle = FormBorderStyle.None
Me.TopMost = True
SetWindowPos(Me.Handle, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW)
End Sub
Public Sub NormalMode()
Me.WindowState = FormWindowState.Normal
Me.FormBorderStyle = FormBorderStyle.SizableToolWindow
Me.TopMost = False
End Sub
PrivateConst SM_CXSCREEN AsInteger=0
PrivateConst SM_CYSCREEN AsInteger=1
PrivateShared HWND_TOP As IntPtr = IntPtr.Zero
PrivateConst SWP_SHOWWINDOW AsInteger=64
PrivateDeclareFunction SetWindowPos Lib "user32.dll"Alias"SetWindowPos"(ByVal hWnd As IntPtr, ByVal hWndIntertAfter As IntPtr, ByVal X AsInteger, ByVal Y AsInteger, ByVal cx AsInteger, ByVal cy AsInteger, ByVal uFlags AsInteger)AsBoolean
PrivateDeclareFunction GetSystemMetrics Lib "user32.dll"Alias"GetSystemMetrics"(ByVal Which AsInteger)AsInteger
Dim Settings As ArrayList
Settings.Add("[SETTINGS]")
Settings.Add("AllowFullscreen = 'True'")
Settings.Add("Fuck = ''")
If System.IO.File.Exists(SetFile) = False Then
objINI.CreateSettingsIni(SetFile)
For i As Integer = 0 To Settings.Count
objINI.AddLine(SetFile, Settings.Item(i))
Next i
End If
Public Class Form1
Dim ShowFullNormalMode As New ClsFullScreen
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'FullScreen()
ShowFullNormalMode.FullScreen(Me)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'NormalMode()
ShowFullNormalMode.NormalMode(Me)
End Sub
End Class
PublicClass Form1
Dim ShowFullNormalMode AsNew ClsFullScreen
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click
'FullScreen()
ShowFullNormalMode.FullScreen(Me)
EndSub
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click
Public Class ClsFullScreen
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
Private 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 ReadOnly Property ScreenX() As Integer
Get
Return GetSystemMetrics(SM_CXSCREEN)
End Get
End Property
Private ReadOnly Property ScreenY() As Integer
Get
Return GetSystemMetrics(SM_CYSCREEN)
End Get
End Property
Public Sub FullScreen(ByVal FrmName As Form)
FrmName.WindowState = FormWindowState.Maximized
FrmName.FormBorderStyle = FormBorderStyle.None
FrmName.TopMost = True
SetWindowPos(FrmName.Handle, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW)
End Sub
Public Sub NormalMode(ByVal FrmName As Form)
FrmName.WindowState = FormWindowState.Normal
FrmName.FormBorderStyle = FormBorderStyle.SizableToolWindow
FrmName.TopMost = False
End Sub
End Class
PublicClass ClsFullScreen
PrivateConst SM_CXSCREEN AsInteger=0
PrivateConst SM_CYSCREEN AsInteger=1
PrivateShared HWND_TOP As IntPtr = IntPtr.Zero
PrivateConst SWP_SHOWWINDOW AsInteger=64
PrivateDeclareFunction SetWindowPos Lib "user32.dll"Alias"SetWindowPos"(ByVal hWnd As IntPtr, ByVal hWndIntertAfter As IntPtr, ByVal X AsInteger, ByVal Y AsInteger, ByVal cx AsInteger, ByVal cy AsInteger, ByVal uFlags AsInteger)AsBoolean
PrivateDeclareFunction GetSystemMetrics Lib "user32.dll"Alias"GetSystemMetrics"(ByVal Which AsInteger)AsInteger