Class

DesktopDisplay

Screen

Display

Monitor


Description

Used to get information about the connected displays.

Methods

Name

Parameters

Returns

Shared

DisplayAt

index As Integer

DesktopDisplay

Property descriptions


DesktopDisplay.AvailableHeight

AvailableHeight As Integer

The available height (in pixels) of the specified display, taking into account the menubar and/or the taskbar (Dock on macOS), if present.

This property is read-only.

Use the DisplayAt method to call AvailableHeight. For example, DisplayAt(0).AvailableHeight returns the available height of the main display.


DesktopDisplay.AvailableLeft

AvailableLeft As Integer

The starting position of the left edge of the specified display. This would be zero unless, for example, the user had placed the taskbar (Windows and Linux) or the Dock (macOS) on the left.

This property is read-only.

Use the DisplayAt method to call AvailableLeft. For example, DisplayAt(0).AvailableLeft returns the available left number of points of the main display.


DesktopDisplay.AvailableTop

AvailableTop As Integer

The starting position of the top edge of the specified display after taking into account the height of any menubar or taskbar, if present.

This property is read-only.

Use the DisplayAt method to call AvailableTop. For example, DisplayAt(0).AvailableTop returns the available top number of pixels of the main display.


DesktopDisplay.AvailableWidth

AvailableWidth As Integer

The available width (in pixels) of the display, taking into account the taskbar if placed on the left or right of the specified display.

This property is read-only.

Use the DisplayAt method to call AvailableWidth. For example, DisplayAt(0).AvailableWidth returns the available width of the main display.


DesktopDisplay.ColorDepth

ColorDepth As Integer

The color depth (in bits) of the display. Most screens use 32-bit color.

This property is read-only.

This example returns the depth of the user's main display:

Var cd As Integer = DesktopDisplay.DisplayAt(0).ColorDepth

DesktopDisplay.DisplayCount

DisplayCount As Integer

Used to determine the number of displays connected to the user's computer.

This property is read-only.

This property is shared.

The DisplayCount function returns the number of displays (monitors) connected to the user's computer (Windows and Macintosh). On Linux, DisplayCount always returns 1.

This example reports on the number of monitors attached to the user's computer.

Var myDisplays As Integer
myDisplays = DesktopDisplay.DisplayCount
If myDisplays = 1 Then
  MessageBox("You have only one display.")
Else
  MessageBox("You have " + myDisplays.ToString + " displays!")
End If

DesktopDisplay.Height

Height As Integer

The height of the display in points. Use the DisplayAt method to call Height. For example, DisplayAt(0).Height returns the height of the main display.

This property is read-only.

Note

This value is scaled based upon the ScaleFactor.


DesktopDisplay.LastDisplayIndex

LastDisplayIndex As Integer

The index of the last display connected to the user's computer. Display 0 is the main display. This can be useful when you need to loop through the user's displays.

This property is read-only.

This property is shared.

This example finds the maximum screen depth of all displays connected to the user's computer:

Var maxDepth As Integer
For i As Integer = 0 To DesktopDisplay.LastDisplayIndex
  Var currentDisplayDepth As Integer
  currentDisplayDepth = DesktopDisplay.DisplayAt(i).ColorDepth
  If currentDisplayDepth > maxDepth Then
    maxDepth = currentDisplayDepth
  End If
Next

DesktopDisplay.Left

Left As Integer

The left coordinate of the screen relative to the main display. For the main display, it is zero. Use the DisplayAt method to call Left. For example, DisplayAt(0).Left returns the left coordinate of the main display.

This property is read-only.


DesktopDisplay.ScaleFactor

ScaleFactor As Double

The ScaleFactor for the display.

This property is read-only.

Note

A ScaleFactor of 1.0 indicates that each point refers to a single pixel on the screen. Higher values indicate a HiDPI display of some kind is being used.

Var scale As Double = DesktopDisplay.DisplayAt(0).ScaleFactor

DesktopDisplay.Top

Top As Integer

The top coordinate of the display relative to the main display. For the main display, it is zero. Use the DisplayAt method to call Top. For example, DisplayAt(0).Top returns the top coordinate of the main display.

This property is read-only.


DesktopDisplay.Width

Width As Integer

The width of the display. Use the DisplayAt method to call Width. For example, DisplayAt(0).Width returns the width of the main display.

This property is read-only.

Note

This value is scaled based upon the ScaleFactor.

Method descriptions


DesktopDisplay.DisplayAt

DisplayAt(index As Integer) As DesktopDisplay

Used to access the properties of a DesktopDisplay object. Returns a reference to the display passed.

This method is shared.

Use this function to access the display properties for the monitors attached to the user's computer. Display 0 is the main screen. You can use the DisplayCount function to determine how many screens exist.

This example displays the size of the user's main display.

MessageBox("Your main display is " + DesktopDisplay.DisplayAt(0).Width.ToString + _
  " by " + DesktopDisplay.DisplayAt(0).Height.ToString + ".")

Notes

Although you cannot create an object of type DesktopDisplay, you can access display objects through the DesktopDisplay class.

Sample code

The following reports on the values of AvailableLeft, AvailableHeight, AvailableTop, and AvailableWidth for the main display. The value of AvailableHeight takes into account the height of the taskbar (Windows and Linux) and the Dock (macOS). If the user has these tools configured to display on the side, the AvailableWidth property takes them into account.

Var s As String
s = "Left=" + DesktopDisplay.DisplayAt(0).AvailableLeft.ToString + EndOfLine
s = s + "Width=" + DesktopDisplay.DisplayAt(0).AvailableWidth.ToString + EndOfLine
s = s + "Top=" + DesktopDisplay.DisplayAt(0).AvailableTop.ToString + EndOfLine
s = s + "Height=" + DesktopDisplay.DisplayAt(0).AvailableHeight.ToString + EndOfLine
MessageBox(s)

Compatibility

Desktop projects on all supported operating systems.