Masalah yang paling besar bagi pembuat aplikasi adalah menentukan resolusi yang pas bagi semua user/pengguna,padahal user pasti memiliki spesifikasi monitor yang berbeda-beda, dibawah ini adalah sedikit tip trick mengenai resolusi bagi user agar pada saat menggunakan aplikasi yang kita buat maka aplikasi akan terlihat bagus dan pas.
Masukan Code di bawah ini pada Form
===================================
Private Sub Form_Load()
'Menentukan resolusi ke 800 x 600 dengan
Dim DevM As DEVMODE
'memasukan info ke dalam DevM
erg& = EnumDisplaySettings(0&, 0&, DevM)
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT 'atau DM_BITSPERPEL
DevM.dmPelsWidth = 800 'ScreenWidth
DevM.dmPelsHeight = 600 'ScreenHeight
'DevM.dmBitsPerPel = 32 (menentukan 8, 16, 32 atau 4)
'Sekarang memilih tampilan dan cek keberhasilan
erg& = ChangeDisplaySettings(DevM, CDS_TEST)
'jika cek berhasil
Select Case erg&
Case DISP_CHANGE_RESTART
an = MsgBox("Maaf anda harus reboot", vbYesNo + vbSystemModal, "Info")
If an = vbYes Then
erg& = ExitWindowsEx(EWX_REBOOT, 0&)
End If
Case DISP_CHANGE_SUCCESSFUL
erg& = ChangeDisplaySettings(DevM, CDS_UPDATEREGISTRY)
MsgBox "Layar Resolusi dirubah menjadi 800x600.", vbOKOnly + vbSystemModal, "Informasi Perubahan Resolusi"
Case Else
MsgBox "Maaf, Resolusi 800x600 tidak didukung Monitor anda", vbOKOnly + vbSystemModal, "Error"
End Select
End Sub
Masukan Code Dibawah ini pada Modul
====================================
Public Const EWX_LOGOFF = 0
Public Const EWX_SHUTDOWN = 1
Public Const EWX_REBOOT = 2
Public Const EWX_FORCE = 4
Public Const CCDEVICENAME = 32
Public Const CCFORMNAME = 32
Public Const DM_BITSPERPEL = &H40000
Public Const DM_PELSWIDTH = &H80000
Public Const DM_PELSHEIGHT = &H100000
Public Const CDS_UPDATEREGISTRY = &H1
Public Const CDS_TEST = &H4
Public Const DISP_CHANGE_SUCCESSFUL = 0
Public Const DISP_CHANGE_RESTART = 1
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
Declare Function ExitWindowsEx Lib "user32" _
(ByVal uFlags As Long, ByVal dwReserved As Long) As Long
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
Semoga bermanfaat.
Bagikan
Thanks banget... tutor ini sangat membantu...
ReplyDeleteTerimakasih kembali Mas az..^_^
ReplyDeleteSiang Gan, mengembalikan ke resolusi awal sebelum aplikasi running giman ya mas bos. setelah ngikuti setting aplikasi resolusi komputer orang jadi berubah? thanks
ReplyDeletety mas postingannya .... sangt bermanfaat
ReplyDelete