|
-
Jun 22nd, 2005, 11:19 PM
#1
Thread Starter
Fanatic Member
how to 800x600pixel 16bit color on form load(RESOLVED)
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
Last edited by ksuwanto8ksd; Jun 23rd, 2005 at 12:47 AM.
-
Jun 23rd, 2005, 12:01 AM
#2
Re: how to 800x600pixel 16bit color on form load
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
-
Jun 23rd, 2005, 12:17 AM
#3
Thread Starter
Fanatic Member
Re: how to 800x600pixel 16bit color on form load
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
-
Jun 23rd, 2005, 12:24 AM
#4
Re: how to 800x600pixel 16bit color on form load
Well, just copy and paste the above code to your Form and add the following to Form_Load
VB Code:
Private Sub Form_Load()
Call RestoreMySettings
End Sub
-
Jun 23rd, 2005, 12:42 AM
#5
Thread Starter
Fanatic Member
Re: how to 800x600pixel 16bit color on form load
Hi Joacim
It work fine
Appreciated.thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|