Berikut ini saya bagikan lagi sebuah kode program untuk mengubah resolusi monitor komputer dengan menggunakan VB 6.0 (Visual Basic 6.0).
Berikut contoh cara pembuatannya:
- Buat Project VB 6.0 baru.
- Pada Form yang aktif tambahkan 4 Commandbutton seperti pada gambar di atas.
- Tambahkan 1 Module dengan cara pilih menu Project --> Add Module dan copy paste kode di bawah ini ke dalam Module.
- Copy paste kode di bawah ini ke dalam Form.
- Jalankan program dan lihat hasilnya. Selesai dan terima kasih.
Private Declare Function EnumDisplaySettings Lib "user32.dll" Alias "EnumDisplaySettingsA" _
(ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean
Private Declare Function ChangeDisplaySettings Lib "user32.dll" Alias "ChangeDisplaySettingsA" _
(lpDevMode As Any, ByVal dwFlags As Long) As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Type DEVMODE
dmDeviceName As String * 32
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * 32
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
'ini adalah codingnya
Public Function changeResolution(ByVal width As Integer, ByVal height As Integer)
Dim dev As DEVMODE
EnumDisplaySettings 0, 0, dev
dev.dmFields = &H80000 Or &H100000
dev.dmPelsWidth = width
dev.dmPelsHeight = height
ChangeDisplaySettings dev, &H4
Call ChangeDisplaySettings(dev, &H1)
Call SendMessage(&HFFFF&, &H7E&, 42, ByVal 0&)
End Function
Private Sub Command1_Click()
'changeResolution (lebar, tinggi)
'anda bisa mengubah lebar dan tinggi sesuai yang diinginkan
'contoh
Call changeResolution(1024, 768)
End Sub
Private Sub Command2_Click()
'changeResolution (lebar, tinggi)
Call changeResolution(800, 600)
End Sub
Private Sub Command3_Click()
'changeResolution (lebar, tinggi)
Call changeResolution(1366, 768)
End Sub
Private Sub Command4_Click()
'changeResolution (lebar, tinggi)Call changeResolution(750, 550) End Sub