|
|
Title | List display modes |
Description | |
Keywords | display modes, color resolution, resolution, display size |
Categories | Windows |
|
|
Use the EnumDisplaySettings API function to list the display settings. Note that this function's first parameter is a string but this program declares it to be of type Long so it can pass a NULL string (address 0) for this parameter.
The second parameter to EnumDisplaySettings gives the index of the desired display mode. The program loops through values starting at 0 until EnumDisplaySettings returns 0 indicating no more values are present.
The program takes the display modes' width, height, and color depth from the DEVMODE structure filled in by EnumDisplaySettings.
After it has made the list of possible display modes, the program uses GetSettings to get the display's current width, height, and color depth, and it selects the entry for those settings.
|
|
Private Sub Form_Load()
Dim dev_mode As DEVMODE
Dim mode_num As Long
' List the display modes.
dev_mode.dmSize = Len(dev_mode)
dev_mode.dmDriverExtra = 0
mode_num = 0
Do While EnumDisplaySettings(0, mode_num, dev_mode) <> 0
lstModes.AddItem _
Format$(dev_mode.dmPelsWidth) & " x " & _
Format$(dev_mode.dmPelsHeight) & " (" & _
Format$(dev_mode.dmBitsPerPel) & " bit)"
mode_num = mode_num + 1
Loop
' Select the current value.
lstModes.Text = _
Format$(GetDeviceCaps(hdc, HORZRES)) & " x " & _
Format$(GetDeviceCaps(hdc, VERTRES)) & " (" & _
Format$(GetDeviceCaps(hdc, BITSPIXEL)) & " bit)"
End Sub
|
|
|
|
|
|