GetDisplaySettings – Retrieve information about available display modes

Const DM_BITSPERPEL As Long = &H40000Const DM_PELSWIDTH As Long = &H80000Const DM_PELSHEIGHT As Long = &H100000Const CCDEVICENAME As Long = 32Const CCFORMNAME As Long = 32Private 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 Long    dmPelsWidth As Long    dmPelsHeight As Long    dmDisplayFlags As Long    dmDisplayFrequency As LongEnd TypePrivate Declare Function EnumDisplaySettings Lib "user32" Alias _    "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, _    ByVal modeIndex As Long, lpDevMode As Any) As Boolean' Fill two arrays with information about all available display modes'' displayInfo() is a bi-dimentional matrix where each row is a display mode'     displayInfo(n, 0) is the horizontal resolution'     displayInfo(n, 1) is the vertical resolution'     displayInfo(n, 2) is the number of colors'     displayInfo(n, 0) is refresh rate (in MHz) or zero if not available' displayDescr() is an array of string that contains the same information'     but in a textual format, ready to be displayed in a menu or listboxSub GetDisplaySettings(displayInfo() As Long, displayDescr() As String)    Dim lpDevMode As DEVMODE    Dim index As Long    Dim displayCount As Long    Dim colorDescr As String        ' set the DEVMODE flags and structure size    lpDevMode.dmSize = Len(lpDevMode)    lpDevMode.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL        ' count how many display settings are there    Do While EnumDisplaySettings(0, displayCount, lpDevMode) > 0        displayCount = displayCount + 1    Loop        ' now displayCount holds the number of display settings    ' and we can DIMension the result arrays    ReDim displayInfo(0 To displayCount - 1, 0 To 3) As Long    ReDim displayDescr(0 To displayCount - 1) As String        For index = 0 To displayCount - 1        ' retrieve info on the Nth display mode        EnumDisplaySettings 0, index, lpDevMode        ' fill the displayInfo structure        displayInfo(index, 0) = lpDevMode.dmPelsWidth        displayInfo(index, 1) = lpDevMode.dmPelsHeight        displayInfo(index, 2) = 2 ^ IIf(lpDevMode.dmBitsPerPel > 24, 24, _            lpDevMode.dmBitsPerPel)        If lpDevMode.dmDisplayFrequency > 1 Then            displayInfo(index, 0) = lpDevMode.dmDisplayFrequency        End If        ' prepare a description for this display mode        Select Case displayInfo(index, 2)            Case 16                colorDescr = "16 colors"            Case 256                colorDescr = "256 colors"            Case Is <= 65536                colorDescr = "High color"            Case Else                colorDescr = "True color"        End Select        displayDescr(index) = lpDevMode.dmPelsWidth & " x " & _            lpDevMode.dmPelsHeight & ", " & colorDescr        If lpDevMode.dmDisplayFrequency > 1 Then            displayDescr(index) = displayDescr(index) & ", " & _                lpDevMode.dmDisplayFrequency & " MHz"        End If    NextEnd Sub

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may

man on floor with data

DevX Quick Guide to Data Ingestion

One of the biggest trends of the 21st century is the massive surge in internet usage. With major innovations such as smart technology, social media, and online shopping sites, the internet has become an essential part of everyday life for a large portion of the population. Due to this internet

payment via phone

7 Ways Technology Has Changed Traditional Payments

In today’s digital world, technology has changed how we make payments. From contactless cards to mobile wallets, it’s now easier to pay for goods and services without carrying cash or using a checkbook. This article will look at seven of the most significant ways technology has transformed traditional payment methods.