Results 1 to 8 of 8

Thread: does api have a function that ...

  1. #1

    Thread Starter
    Lively Member wazup guys's Avatar
    Join Date
    Apr 2001
    Location
    in a compressed datastream on the web
    Posts
    114
    can get the screen resolution
    wahuah

    talk to me about macromedia flash mx, Visual Basic, Vbscript, Html

    [email protected]
    [email protected]
    [email protected]

  2. #2
    Addicted Member Xdream's Avatar
    Join Date
    Mar 2001
    Location
    Switzerland
    Posts
    194
    You can use this code example:

    Code:
    'in module: 
    Option Explicit
    
    Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
    
    Private Const SM_CXSCREEN = 0
    Private Const SM_CYSCREEN = 1
    
    ' Check whether screen resolution is set to 800x600
    ' Returns True if the resolution is at 800x600 else
    ' False is returned
    Public Function GetScreenResolution800x600() As Boolean
    Dim lTemp As String
    ' Temporary string to hold returned screen
    ' resolution
    lTemp = GetSystemMetrics(SM_CXSCREEN) & "x" & GetSystemMetrics(SM_CYSCREEN)
    ' Call the API function twice to return
    ' screen size for each axis as format into
    ' the temporary string
    If lTemp = "800x600" Then
      ' Check whether resolution is set to 800x600
      GetScreenResolution800x600 = True
      ' True
    Else
      GetScreenResolution800x600 = False
      ' False
    End If
    End Function
    
    '(in form-commandbutton) 
    
    Private Sub cmdGetRes_Click()
    If GetScreenResolution800x600 = True Then
      MsgBox "Your settings are 800x600", vbInformation
    Else
      MsgBox "Your display settings are not at 800x600", vbExclamation
    End If
    End Sub
    HTH,
    Xdream

  3. #3
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    You don't really need the API for this.
    Code:
    Dim X As Long, Y As Long
    
    X = Screen.Width / Screen.TwipsPerPixelX
    Y = Screen.Height / Screen.TwipsPerPixelY
    
    Call MsgBox("Your resolution is " & X & "x" & Y & " pixels")
    VBBrowser v2.2.1
    But you would need the API if you also want the color depth part of the resolution. Put this in a module:
    Code:
    Option Explicit
    
    Public Const ENUM_CURRENT_SETTINGS = -1
    Public Const CCHDEVICENAME = 32
    Public Const CCHFORMNAME = 32
    
    Public Type DEVMODE
        dmDeviceName As String * CCHDEVICENAME
        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 * CCHFORMNAME
        dmUnusedPadding As Integer
        dmBitsPerPel As Integer
        dmPelsWidth As Long
        dmPelsHeight As Long
        dmDisplayFlags As Long
        dmDisplayFrequency As Long
    End Type
    
    Public Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As String, ByVal iModeNum As Long, lpDevMode As DEVMODE) As Long
    
    Public Function GetResolution() As String
        Dim dm As DEVMODE
        
        Call EnumDisplaySettings(vbNullString, ENUM_CURRENT_SETTINGS, dm)
        
        GetResolution = dm.dmPelsWidth & "x" & dm.dmPelsHeight & " pixels, " & dm.dmBitsPerPel & "-bit color"
    End Function
    VBBrowser v2.2.1
    Then, anywhere in your code, you can use the GetResolution function to get the resolution details including color depth.

  4. #4
    TheSarlacc
    Guest

    omg

    talk about exaggeration bro! here is code that actually does what u want Wazup guys!

    'declarations for resolution changing
    Public 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
    dmBitsPerPixel As Integer
    dmPelsWidth As Long
    dmPelsHeight As Long
    dmDisplayFlags As Long
    dmDisplayFrequency As Long
    dmICMMethod As Long
    dmICMIntent As Long
    dmMediaType As Long
    dmDitherType As Long
    dmReserved1 As Long
    dmReserved2 As Long
    End Type
    Public Declare Function EnumDisplaySettings Lib "user32.dll" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As String, ByVal iModeNum As Long, lpDevMode As DEVMODE) As Long
    Public Declare Function ChangeDisplaySettings Lib "user32.dll" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwFlags As Long) As Long
    Public Const ENUM_CURRENT_SETTINGS = -1

    Dim dm As DEVMODE
    dm.dmSize = Len(dm)
    rval& = EnumDisplaySettings(vbNullString, ENUM_CURRENT_SETTINGS, dm)

    =============
    dm.pelswidth is ur x resolution
    dm.pelsheight is ur y resolution

  5. #5
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Is my code exaggerated? Then why's your code so similar to mine?

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Probably because there's only a 2-minute difference, so I expect he was referring to an earlier post

    Damn you've got me started now
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Originally posted by parksie
    Damn you've got me started now
    You'll get over it

  8. #8

    Thread Starter
    Lively Member wazup guys's Avatar
    Join Date
    Apr 2001
    Location
    in a compressed datastream on the web
    Posts
    114

    Smile hey

    ok u all so u stop acting like little kids. ill test out all of the code and the one that works the best and is the fastest plus smallest amount of code
    and if u think u have code thats alot better than any thing posted please give ur ideas
    wahuah

    talk to me about macromedia flash mx, Visual Basic, Vbscript, Html

    [email protected]
    [email protected]
    [email protected]

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