screen resolution


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: screen resolution

  1. #1
    Join Date
    Apr 2005
    Posts
    31

    Question screen resolution

    i am working on a game and need to make it full screen i've made a module and when the form loads the screen resolution changes but how do i record the screen rosolution before the resolution is changed so that i can restore it.

    please help

    thanks you very much

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    how do you change the screen resolution at start up?
    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  3. #3
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Code:
    With Screen
        Horz = .Width \ .TwipsPerPixelX
        Vert = .Height \ .TwipsPerPixelY
    End With
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  4. #4
    Join Date
    Apr 2005
    Posts
    31
    here is the code of my module
    Code:
    Option Explicit
    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
           Const CCDEVICENAME = 32
           Const CCFORMNAME = 32
           Const DM_PELSWIDTH = &H80000
           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
    Dim DevM As DEVMODE
    
    Sub ChangeRes(iWidth As Single, iHeight As Single)
    
           Dim a As Boolean
           Dim I&
           I = 0
    
                  Do
                         a = EnumDisplaySettings(0&, I&, DevM)
                         I = I + 1
                  Loop Until (a = False)
    
           Dim b&
           DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
           DevM.dmPelsWidth = iWidth
           DevM.dmPelsHeight = iHeight
           b = ChangeDisplaySettings(DevM, 0)
    End Sub

    In the form load i placed
    Code:
    Call ChangeRes(600, 800)
    but i dont know how to change it back to what it used to be

  5. #5
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    declare this at module level:

    private m_origPelsWidth as long
    private m_origPelsHeight as long

    after EnumDisplaySettings, save them before changing:

    m_origPelsWidth = DevM.dmPelsWidth
    m_origPelsHeight = DevM.dmPelsHeight

    Then in your form unload (or wherever more convenient) call again ChangeDisplaySettings after restoring the original values

    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center