can get the screen resolution
Printable View
can get the screen resolution
You can use this code example:
HTH,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
Xdream
You don't really need the API for this. :rolleyes:
But you would need the API if you also want the color depth part of the resolution. Put this in a module: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
Then, anywhere in your code, you can use the GetResolution function to get the resolution details including color depth.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
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
Is my code exaggerated? Then why's your code so similar to mine? :rolleyes:
Probably because there's only a 2-minute difference, so I expect he was referring to an earlier post :rolleyes:
Damn you've got me started now :rolleyes:
You'll get over it :rolleyes:Quote:
Originally posted by parksie
Damn you've got me started now :rolleyes:
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 :)