Cara Mengganti Resolusi Layar Monitor VB6
Berikut ini adalah cara mengganti resolusi layar monitor Anda menggunakan visual basic 6, untuk mempraktekannya siapkan :
1. Buat 1 Project baru dengan 1 Module dan 1 Form.2. Copy-kan coding berikut ke dalam editor Module dan form ybt.
'Program akan mengkonfirmasikan ke Anda jika komputer harus di-restart
'untuk menyimpan perubahan.
'--- Coding ini di Module Anda...
Public Const CCDEVICENAME = 32
Public Const CCFORMNAME = 32
Public Const DISP_CHANGE_SUCCESSFUL = 0
Public Const DISP_CHANGE_RESTART = 1
Public Const DISP_CHANGE_FAILED = -1
Public Const DISP_CHANGE_BADMODE = -2
Public Const DISP_CHANGE_NOTUPDATED = -3
Public Const DISP_CHANGE_BADFLAGS = -4
Public Const DISP_CHANGE_BADPARAM = -5
Public Const CDS_UPDATEREGISTRY = &H1
Public Const CDS_TEST = &H2
Public Const DM_BITSPERPEL = &H40000
Public Const DM_PELSWIDTH = &H80000
Public Const DM_PELSHEIGHT = &H100000
Public Type DEVMODE
dmDeviceName As String * CCDEVICENAME
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 * CCFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" _
(ByVal lpszDeviceName As Long, ByVal iModeNum As Long, _
lpDevMode As Any) As Boolean
Declare Function ChangeDisplaySettings Lib "user32" Alias _
"ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwFlags As Long) As Long
'--- Akhir coding di Module...
'--- Coding ini di Form Anda...
Private Sub Form_Load()
'Ganti '800,600' dengan resolusi yang Anda inginkan.
'Anda dapat mengganti "color pallete" ke 32 - Bit dengan mengganti '16' di bawah dengan '32'
'ChangeScreenSettings 640, 480, 16 - Bit 'Contoh apabila menggunakan 640x480, 16 Bit
ChangeScreenSettings 800, 600, 16 - Bit 'Contoh yang diaplikasikan saat ini.
End Sub
Public Sub ChangeScreenSettings(lWidth As Integer, _
lHeight As Integer, lColors As Integer)
Dim tDevMode As DEVMODE, lTemp As Long, lIndex As Long
lIndex = 0
Do
lTemp = EnumDisplaySettings(0&, lIndex, tDevMode)
If lTemp = 0 Then Exit Do
lIndex = lIndex + 1
With tDevMode
If .dmPelsWidth = lWidth And .dmPelsHeight = lHeight _
And .dmBitsPerPel = lColors Then
lTemp = ChangeDisplaySettings(tDevMode, CDS_UPDATEREGISTRY)
Exit Do
End If
End With
Loop
Select Case lTemp
Case DISP_CHANGE_SUCCESSFUL
MsgBox "Setting tampilan baru telah berhasil", _
vbInformation
Case DISP_CHANGE_RESTART
MsgBox "Komputer harus di-restart agar mode grafik dapat berfungsi!", vbQuestion
Case DISP_CHANGE_FAILED
MsgBox "Driver dari tampilan gagal memilih mode grafik!", vbCritical
Case DISP_CHANGE_BADMODE
MsgBox "Mode grafik tidak mendukung!", vbCritical
Case DISP_CHANGE_NOTUPDATED
MsgBox "Tidak dapat menulis setting ke dalam registry", vbCritical
Case DISP_CHANGE_BADFLAGS
MsgBox "Anda memasukkan data yang tidak valid!", vbCritical
End Select
End Sub
'--- Akhir Coding di Form...
Tags:
contoh program vb6, contoh fungsi di vb6, cara penggunaan fungsi vb, tutorial vb6, download tutorial vb6, vb6 tutorial download, dasar dasar vb6, belajar vb6, cara mudah belajar vb6, vb6 artikel download, vb6 blog, contoh program vb6, artikel vb6, semua tentang vb6, vb6 api, cara menggunakan module, cara menggunakan class module
Posting Komentar untuk "Cara Mengganti Resolusi Layar Monitor VB6"