My system is winme base and I want to make default 800x600pixel 16 bit color when form load. because some game always change the resolution to 640x480. and I want it turn to my default res when game exit.
Any help is greatly appreciated
Printable View
My system is winme base and I want to make default 800x600pixel 16 bit color when form load. because some game always change the resolution to 640x480. and I want it turn to my default res when game exit.
Any help is greatly appreciated
Bad game designers that doesn't restore the display settings.... To change the resolution you should first call the EnumDisplaySettings API function to get the information about the current setting. This function will populate a DEVMODE structure with all information you need. You can then change some of the members in this structure and then call the ChangeDisplaySettings API function.VB Code:
Private Declare Function EnumDisplaySettingsNull _ Lib "user32" Alias "EnumDisplaySettingsA" ( _ ByVal lpszDeviceName As Long, _ ByVal iModeNum As Long, _ ByRef lpDevMode As DEVMODE) As Boolean Private Declare Function ChangeDisplaySettings _ Lib "user32" Alias "ChangeDisplaySettingsA" ( _ ByRef lpDevMode As DEVMODE, _ ByVal dwFlags As Long) 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 Private Const DISP_CHANGE_SUCCESSFUL = 0 Private Const DISP_CHANGE_RESTART = 1 Private Const DM_BITSPERPEL As Long = &H40000& Private Const DM_PELSHEIGHT As Long = &H100000& Private Const DM_PELSWIDTH As Long = &H80000& Private Const CDS_UPDATEREGISTRY = &H1 Public Sub RestoreMySettings() Dim dm As DEVMODE dm.dmSize = Len(dm) Call EnumDisplaySettingsNull(0&, 0&, dm) With dm .dmFields = DM_BITSPERPEL Or DM_PELSHEIGHT Or DM_PELSWIDTH .dmPelsWidth = 800 .dmPelsHeight = 600 .dmBitsPerPel = 16 End With Select Case ChangeDisplaySettings(dm, CDS_UPDATEREGISTRY) Case DISP_CHANGE_RESTART MsgBox "You need to restart for these changes to take effect" Case DISP_CHANGE_SUCCESSFUL MsgBox "Screen resolution changed!" Case Else MsgBox "Could not change the resolution" End Select End Sub
I mean just dont care the default resolution setting or whatever the resolution is. just set to 800x600pixel on form load. But dont know whether it is possible or not
I have already search the forum but none can solved this question
thanks for your reply this appreciated
Well, just copy and paste the above code to your Form and add the following to Form_LoadVB Code:
Private Sub Form_Load() Call RestoreMySettings End Sub
Hi Joacim
It work fine
Appreciated.thanks