Results 1 to 2 of 2

Thread: How to change a screens resolution

  1. #1

    Thread Starter
    Addicted Member Buy2easy.com's Avatar
    Join Date
    Jul 2002
    Posts
    200

    How to change a screens resolution

    O.K. here is what i have. I have a program that runs great on a screen resolution that is higher but does not need to be on a resolution of 680 x 320. Is there any way that i can change a computers resolution when a program starts but when the program ends change it back to its normal resolution. If so, how?

    THANKS!!

  2. #2

    Thread Starter
    Addicted Member Buy2easy.com's Avatar
    Join Date
    Jul 2002
    Posts
    200
    Could someone convert the following into something that i can use in .net i need to be able to change the screen resolution but this code is in vb 6 and some of the things make errors and i can not figure out why? Thanks a lot guys!

    Private Declare Function EnumDisplaySettings Lib "user32" _
    Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As _
    Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean
    Private Declare Function ChangeDisplaySettings Lib "user32" _
    Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal _
    dwflags As Long) As Long
    Private Const CCDEVICENAME = 32
    Private Const CCFORMNAME = 32
    Private Const DM_PELSWIDTH = &H80000
    Private Const DM_PELSHEIGHT = &H100000
    Private 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
    Sub ChangeRes(iWidth As Single, iHeight As Single)
    Dim lReturn As Boolean
    Dim iVal As Long
    Dim DevM As DEVMODE

    iVal = 0
    Do
    lReturn = EnumDisplaySettings(0&, iVal, DevM)
    iVal = iVal + 1
    Loop Until (lReturn = False)
    DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
    DevM.dmPelsWidth = iWidth
    DevM.dmPelsHeight = iHeight
    iVal = ChangeDisplaySettings(DevM, 0)
    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