Results 1 to 3 of 3

Thread: Screen resolution

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    Huntsville, AR 72740, USA
    Posts
    90

    Question Screen resolution

    At the start of the application I need to set the screen to a specific size. How would I do this?
    To Seek is to start on the never ending road to wisdom. To fail to seek, the path to death.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Try this out:
    VB Code:
    1. Public Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" _
    2. (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean
    3.  
    4. Public Declare Function ChangeDisplaySettings Lib "user32" _
    5. Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwFlags As Long) As Long
    6.  
    7. Public Const CCDEVICENAME = 32
    8. Public Const CCFORMNAME = 32
    9. Public Const DM_BITSPERPEL = &H40000
    10. Public Const DM_PELSWIDTH = &H80000
    11. Public Const DM_PELSHEIGHT = &H100000
    12. Public Const CDS_UPDATEREGISTRY = &H1
    13. Public Const CDS_TEST = &H4
    14. Public Const DISP_CHANGE_SUCCESSFUL = 0
    15. Public Const DISP_CHANGE_RESTART = 1
    16. Type DEVMODE
    17.     dmDeviceName As String * CCDEVICENAME
    18.     dmSpecVersion As Integer
    19.     dmDriverVersion As Integer
    20.     dmSize As Integer
    21.     dmDriverExtra As Integer
    22.     dmFields As Long
    23.     dmOrientation As Integer
    24.     dmPaperSize As Integer
    25.     dmPaperLength As Integer
    26.     dmPaperWidth As Integer
    27.     dmScale As Integer
    28.     dmCopies As Integer
    29.     dmDefaultSource As Integer
    30.     dmPrintQuality As Integer
    31.     dmColor As Integer
    32.     dmDuplex As Integer
    33.     dmYResolution As Integer
    34.     dmTTOption As Integer
    35.     dmCollate As Integer
    36.     dmFormName As String * CCFORMNAME
    37.     dmUnusedPadding As Integer
    38.     dmBitsPerPel As Integer
    39.     dmPelsWidth As Long
    40.     dmPelsHeight As Long
    41.     dmDisplayFlags As Long
    42.     dmDisplayFrequency As Long
    43. End Type
    44.  
    45.  
    46. Public Sub ChangeScreenSettings()
    47. Dim DevM As DEVMODE
    48. Dim Ans As Long
    49. Dim erg As Long
    50. 'Get the info into DevM
    51. erg& = EnumDisplaySettings(0&, 0&, DevM)
    52. 'We don't change the colordepth, because a
    53. 'rebot will be necessary
    54.  
    55. DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT 'Or DM_BITSPERPEL
    56. DevM.dmPelsWidth = 1024 'ScreenWidth
    57. DevM.dmPelsHeight = 768 'ScreenHeight
    58. DevM.dmBitsPerPel = 32  '(could be 8, 16, 32 or even 4)
    59.  
    60. 'Now change the display and check if possible
    61. erg& = ChangeDisplaySettings(DevM, CDS_TEST)
    62.  
    63. 'Check if successful
    64. Select Case erg&
    65. Case DISP_CHANGE_RESTART
    66.     Ans = MsgBox("You must reboot for the new resolution to take efect!", vbYesNo + vbSystemModal, "Info")
    67.     If Ans = vbYes Then
    68.         erg& = ExitWindowsEx(EWX_REBOOT, 0&)
    69.     End If
    70. Case DISP_CHANGE_SUCCESSFUL
    71.     erg& = ChangeDisplaySettings(DevM, CDS_UPDATEREGISTRY)
    72. Case Else
    73.     MsgBox "Your Graphics card must be able to support 1024 x 768 resolution!", vbOKOnly + vbSystemModal, "Error"
    74. End Select
    75. End Sub

  3. #3
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    VB Code:
    1. Private Sub Form_Initialize()
    2. Form1.Height = 3332
    3. Form1.Width = 9372
    4. End Sub

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