Results 1 to 5 of 5

Thread: how to 800x600pixel 16bit color on form load(RESOLVED)

  1. #1

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Resolved 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.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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:
    1. Private Declare Function EnumDisplaySettingsNull _
    2.  Lib "user32" Alias "EnumDisplaySettingsA" ( _
    3.  ByVal lpszDeviceName As Long, _
    4.  ByVal iModeNum As Long, _
    5.  ByRef lpDevMode As DEVMODE) As Boolean
    6.  
    7. Private Declare Function ChangeDisplaySettings _
    8.  Lib "user32" Alias "ChangeDisplaySettingsA" ( _
    9.  ByRef lpDevMode As DEVMODE, _
    10.  ByVal dwFlags As Long) As Long
    11.  
    12. Private Type DEVMODE
    13.     dmDeviceName As String * 32
    14.     dmSpecVersion As Integer
    15.     dmDriverVersion As Integer
    16.     dmSize As Integer
    17.     dmDriverExtra As Integer
    18.     dmFields As Long
    19.     dmOrientation As Integer
    20.     dmPaperSize As Integer
    21.     dmPaperLength As Integer
    22.     dmPaperWidth As Integer
    23.     dmScale As Integer
    24.     dmCopies As Integer
    25.     dmDefaultSource As Integer
    26.     dmPrintQuality As Integer
    27.     dmColor As Integer
    28.     dmDuplex As Integer
    29.     dmYResolution As Integer
    30.     dmTTOption As Integer
    31.     dmCollate As Integer
    32.     dmFormName As String * 32
    33.     dmUnusedPadding As Integer
    34.     dmBitsPerPel As Integer
    35.     dmPelsWidth As Long
    36.     dmPelsHeight As Long
    37.     dmDisplayFlags As Long
    38.     dmDisplayFrequency As Long
    39. End Type
    40.  
    41. Private Const DISP_CHANGE_SUCCESSFUL = 0
    42. Private Const DISP_CHANGE_RESTART = 1
    43. Private Const DM_BITSPERPEL As Long = &H40000&
    44. Private Const DM_PELSHEIGHT As Long = &H100000&
    45. Private Const DM_PELSWIDTH As Long = &H80000&
    46. Private Const CDS_UPDATEREGISTRY = &H1
    47.  
    48. Public Sub RestoreMySettings()
    49.     Dim dm As DEVMODE
    50.  
    51.     dm.dmSize = Len(dm)
    52.     Call EnumDisplaySettingsNull(0&, 0&, dm)
    53.     With dm
    54.         .dmFields = DM_BITSPERPEL Or DM_PELSHEIGHT Or DM_PELSWIDTH
    55.         .dmPelsWidth = 800
    56.         .dmPelsHeight = 600
    57.         .dmBitsPerPel = 16
    58.     End With
    59.     Select Case ChangeDisplaySettings(dm, CDS_UPDATEREGISTRY)
    60.         Case DISP_CHANGE_RESTART
    61.             MsgBox "You need to restart for these changes to take effect"
    62.         Case DISP_CHANGE_SUCCESSFUL
    63.             MsgBox "Screen resolution changed!"
    64.         Case Else
    65.             MsgBox "Could not change the resolution"
    66.     End Select
    67. End Sub

  3. #3

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    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

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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:
    1. Private Sub Form_Load()
    2.     Call RestoreMySettings
    3. End Sub

  5. #5

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    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
  •  



Click Here to Expand Forum to Full Width