15.7 Class Screens (gb. qt4)

The Screens class has only one property. Count returns the number of monitors connected to your system's graphics card.

B1

Figure 15.7.1: Display of the number of monitors on the graphics card

Good to know you're using screens[ Index As Integer] As Screen a screen object that allows you to read the screen geometry of a particular monitor. The standard monitor has the index 0:

Public Sub btnGetMonitorGeometry_Click()
 Dim sMessage As String
 
  sMessage = "<hr><b>Monitor-Eigenschaften</b><hr>"
  sMessage &= "Monitor-Höhe = " & Screens[0].Height & " Pixel"
  sMessage &= "<br>Monitor-Breite = " & Screens[0].Width & " Pixel"
  sMessage &= "<br><br>Nutzbare Desktop-Höhe = " & Screens[0].AvailableHeight & " Pixel"
  sMessage &= "<br>Nutzbare Desktop-Breite = " & Screens[0].AvailableWidth & " Pixel<br>"
  sMessage &= "<br>Auflösung = " & Desktop.Resolution & " DPI <hr>"
  Message.Info(sMessage)
 
' Alternativer Quelltext:
 
  ' sMessage = "<hr><b>Standard-Monitor-Eigenschaften</b><hr>"
  ' sMessage &= "Monitor-Höhe = " & Screen.Height & " Pixel"
  ' sMessage &= "<br>Monitor-Breite = " & Screen.Width & " Pixel"
  ' sMessage &= "<br>Auflösung = " & Desktop.Resolution & " DPI <hr>"
  ' sMessage &= "Nutzbare Desktop-Höhe = " & Screens[0].AvailableHeight & " Pixel"
  ' sMessage &= "<br>Nutzbare Desktop-Breite = " & Screens[0].AvailableWidth & " Pixel<br>"
  ' Message.Info(sMessage)
 
  End ' btnGetMonitorGeometry_Click()

B2

Figure 15.7.2: Display of selected monitor properties

The following procedure provides information about the selected properties of the monitors if several monitors are connected to the same graphics card. Pay particular attention to the sections in the source code that are highlighted in blue, which can be extended by additional properties for k monitors:

Public Sub btnGetMonitorGeometry_Click()
  Dim iCount As Integer
  Dim sMessage As String
  Dim hScreen As Screen
 
  sMessage = "<hr><b>Monitor-Eigenschaften</b><hr>"
    For Each hScreen In Screens
        sMessage &= "Höhe Monitor " & Str(iCount + 1) & "  = " & Screens[iCount].Height & " Pixel"
        sMessage &= "<br>Breite Monitor " & Str(iCount + 1) & " = " & Screens[iCount].Width & " Pixel <hr>"
        Inc iCount
    Next ' hScreen
  Message.Info(sMessage) 
 
End ' btnGetMonitorGeometry_Click()

B3

Figure 15.7.3: Displaying Selected Monitor Properties for Multiple Monitors

Download