login  Naam:   Wachtwoord: 
Registreer je!
 Forum

[VB.NET] Fullscreen class (Opgelost)

Offline nick5556 - 06/12/2009 12:40 (laatste wijziging 06/12/2009 13:47)
Avatar van nick5556PHP beginner Hallo,

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?

Groetjes.

BTW dit is de code:

  1. Private Const SM_CXSCREEN As Integer = 0
  2. Private Const SM_CYSCREEN As Integer = 1
  3. Private Shared HWND_TOP As IntPtr = IntPtr.Zero
  4. Private Const SWP_SHOWWINDOW As Integer = 64
  5.  
  6. 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
  7. Private Declare Function GetSystemMetrics Lib "user32.dll" Alias "GetSystemMetrics" (ByVal Which As Integer) As Integer
  8.  
  9.  
  10. Public ReadOnly Property ScreenX() As Integer
  11. Get
  12. Return GetSystemMetrics(SM_CXSCREEN)
  13. End Get
  14. End Property
  15.  
  16. Public ReadOnly Property ScreenY() As Integer
  17. Get
  18. Return GetSystemMetrics(SM_CYSCREEN)
  19. End Get
  20. End Property
  21.  
  22. Private Sub FullScreen()
  23. Me.WindowState = FormWindowState.Maximized
  24. Me.FormBorderStyle = FormBorderStyle.None
  25. Me.TopMost = True
  26. SetWindowPos(Me.Handle, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW)
  27. End Sub
  28.  
  29. Public Sub NormalMode()
  30. Me.WindowState = FormWindowState.Normal
  31. Me.FormBorderStyle = FormBorderStyle.SizableToolWindow
  32. Me.TopMost = False
  33. End Sub


EDIT:
Waarom geeft mijn arraylist een error? Ik kom er zelf even niet meer uit. Dit is de code:

  1. Dim Settings As ArrayList
  2. Settings.Add("[SETTINGS]")
  3. Settings.Add("AllowFullscreen = 'True'")
  4. Settings.Add("Fuck = ''")
  5. If System.IO.File.Exists(SetFile) = False Then
  6. objINI.CreateSettingsIni(SetFile)
  7. For i As Integer = 0 To Settings.Count
  8. objINI.AddLine(SetFile, Settings.Item(i))
  9. Next i
  10. End If

2 antwoorden

Gesponsorde links
Offline Mario - 07/12/2009 10:18
Avatar van Mario Crew algemeen De oplossing op je eerste vraag.

mvg,
Mario

  1. Public Class Form1
  2.  
  3. Dim ShowFullNormalMode As New ClsFullScreen
  4.  
  5. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  6. 'FullScreen()
  7. ShowFullNormalMode.FullScreen(Me)
  8. End Sub
  9.  
  10. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  11. 'NormalMode()
  12. ShowFullNormalMode.NormalMode(Me)
  13. End Sub
  14. End Class


  1. Public Class ClsFullScreen
  2.  
  3. Private Const SM_CXSCREEN As Integer = 0
  4. Private Const SM_CYSCREEN As Integer = 1
  5. Private Shared HWND_TOP As IntPtr = IntPtr.Zero
  6. Private Const SWP_SHOWWINDOW As Integer = 64
  7.  
  8. 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
  9. Private Declare Function GetSystemMetrics Lib "user32.dll" Alias "GetSystemMetrics" (ByVal Which As Integer) As Integer
  10.  
  11. Private ReadOnly Property ScreenX() As Integer
  12. Get
  13. Return GetSystemMetrics(SM_CXSCREEN)
  14. End Get
  15. End Property
  16.  
  17. Private ReadOnly Property ScreenY() As Integer
  18. Get
  19. Return GetSystemMetrics(SM_CYSCREEN)
  20. End Get
  21. End Property
  22.  
  23. Public Sub FullScreen(ByVal FrmName As Form)
  24. FrmName.WindowState = FormWindowState.Maximized
  25. FrmName.FormBorderStyle = FormBorderStyle.None
  26. FrmName.TopMost = True
  27. SetWindowPos(FrmName.Handle, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW)
  28. End Sub
  29.  
  30. Public Sub NormalMode(ByVal FrmName As Form)
  31. FrmName.WindowState = FormWindowState.Normal
  32. FrmName.FormBorderStyle = FormBorderStyle.SizableToolWindow
  33. FrmName.TopMost = False
  34. End Sub
  35.  
  36.  
  37. End Class
Offline nick5556 - 07/12/2009 18:01
Avatar van nick5556 PHP beginner Oke, dankjewel!

BTW: ik heb de tweede al opgelost via een string met meerdere indexen(zo zeg je dat toch???).
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.184s