User Tools

Site Tools


k15:k15.4:start

15.4 Class DesktopWindow (gb. desktop)

The class DesktopWindow (gb. desktop) represents a top-level window. You can create objects of the class in this way:

Dim hDesktopWindow As DesktopWindow
hDesktopWindow = New DesktopWindow(Window As Integer)

However, it is recommended that you do not create DesktopWindow objects directly, but rather access a top-level window using the Desktop. Windows property. Two examples should prove this:

Private Function Desktop_FindWindow(sPattern As String) As DesktopWindow[]
  Dim dtWindow As DesktopWindow
  Dim dtWList As New DesktopWindow[]
 
  Desktop.Windows.Refresh()
 
' Desktop.Windows presents a list of all top-level windows as a virtual object.
  For Each dtWindow In Desktop.Windows
      If dtWindow.Name Like sPattern Then
         dtWList.Add(dtWindow)
      Endif '  dtWindow.Name Like sPattern ?
  Next ' dtWindow
 
  Return dtWList
End ' Function Desktop_FindWindow(..)
Public Sub btnExample_Click()
  Dim dtWindow As DesktopWindow
 
  Desktop.Windows.Refresh()
 
  For Each dtWindow In Desktop.Windows
    If dtWindow.SkipTaskbar = False Then
       Print "Window.Name = \"" & dtWindow.Name & "\" , X = " & dtWindow.X & " , Y = " & dtWindow.Y
    Endif ' dtWindow.SkipTaskbar = False
  Next ' dtWindow
 
End ' btnExample_Click()

The last section of the source code, for example, provides the following output in the console (IDE):

Window.Name = "Gambas Documentation - Desktop.Windows[] (gb.desktop) - Mozilla Firefox" , X = 0 , Y = 24 
Window.Name = "19.7.4.odt - LibreOffice Writer" , X = 0 , Y = 24 
Window.Name = "19.7_Desktop" , X = 0 , Y = 24 
Window.Name = "k19:start [GAMBAS-BUCH 3.5.1] - Mozilla Firefox" , X = 0 , Y = 24 
Window.Name = "propertytest 0.0.15 - Gambas 3" , X = 0 , Y = 24 
Window.Name = "PropertyTest" , X = 304 , Y = 213

15.4.1 Properties

Selected properties and methods of the class are listed and described in the following two tables:

tablelayout

PropertyTypeDescription
Desktop IntegerReturns the number (0.. k) of the virtual desktop where the window is visible or sets the number of the desktop where the window is displayed.
IconImageReturns the window icon.
IdIntegerReturns the X11 window identifier.
FullScreen BooleanSpecifies whether the window is in full screen state or sets the full screen state.
HeightIntegerSpecifies the height of the window (pixels).
WidthIntegerSpecifies the width of the window (pixels).
MaximizedBooleanReturns True if the window is maximized or maximizes the window.
MinimizedBooleanReturns True if the window is minimized or minimizes the window.
NameStringSpecifies the name of the window. This is the window title of the application that owns this window.
StickyBooleanReturns True if the window is displayed on all desktops or displays the window on all desktops.
VisibleStringReturns the visible name of the window. This is the window title as displayed by the window manager.
XIntegerReturns the x-coordinate of the window.
YIntegerReturns the y-coordinate of the window.

Table 15.4.1.1: Overview of selected properties of the DesktopWindow class

15.4.2 Methods

tablelayout

MethodDescription
Close() Closes the window.
GetIcon(Width As Integer, Height As Integer) As ImageReturns the window icon with the specified size.
Move(X As Integer, Y As Integer[, Width As Integer, Height As Integer]The window is moved to the position P(x,y) and optionally resized (width) and height.
Refresh()Restores a DesktopWindow object by querying the geometry of the window. This happens automatically with a DesktopWatcher.WindowGeometry event.
Resize(Width As Integer, Height As Integer)The window is only resized in size (height and width).

Table 15.4.2.1: Selected methods of the DesktopWindow class

For more information on the DesktopWindow class (gb. desktop), see chapter 15, which demonstrates the practical interaction of the two classes in a project in addition to the description of the DesktopWatcher class.

Download

Articles

Download


15.4 Klasse DesktopWindow (gb.desktop)

Die Klasse DesktopWindow (gb.desktop) repräsentiert ein Top-Level-Fenster. Objekte der Klasse können Sie so anlegen:

Dim hDesktopWindow As DesktopWindow
hDesktopWindow = New DesktopWindow(Window As Integer)

Es wird aber empfohlen, DesktopWindow-Objekte nicht direkt anzulegen, sondern Zugriff auf ein Top-Level-Fenster über die Eigenschaft Desktop.Windows zu bekommen. Zwei Beispiele sollen das belegen:

Private Function Desktop_FindWindow(sPattern As String) As DesktopWindow[]
  Dim dtWindow As DesktopWindow
  Dim dtWList As New DesktopWindow[]
 
  Desktop.Windows.Refresh()
 
' Desktop.Windows präsentiert als virtuelles Objekt eine Liste aller Top-Level-Fenster
  For Each dtWindow In Desktop.Windows
      If dtWindow.Name Like sPattern Then
         dtWList.Add(dtWindow)
      Endif '  dtWindow.Name Like sPattern ?
  Next ' dtWindow
 
  Return dtWList
End ' Function Desktop_FindWindow(..)
Public Sub btnExample_Click()
  Dim dtWindow As DesktopWindow
 
  Desktop.Windows.Refresh()
 
  For Each dtWindow In Desktop.Windows
    If dtWindow.SkipTaskbar = False Then
       Print "Window.Name = \"" & dtWindow.Name & "\" , X = " & dtWindow.X & " , Y = " & dtWindow.Y
    Endif ' dtWindow.SkipTaskbar = False
  Next ' dtWindow
 
End ' btnExample_Click()

Der letzte Quelltext-Ausschnitt liefert beispielsweise folgende Ausgabe in der Konsole (IDE):

Window.Name = "Gambas Documentation - Desktop.Windows[] (gb.desktop) - Mozilla Firefox" , X = 0 , Y = 24 
Window.Name = "19.7.4.odt - LibreOffice Writer" , X = 0 , Y = 24 
Window.Name = "19.7_Desktop" , X = 0 , Y = 24 
Window.Name = "k19:start [GAMBAS-BUCH 3.5.1] - Mozilla Firefox" , X = 0 , Y = 24 
Window.Name = "propertytest 0.0.15 - Gambas 3" , X = 0 , Y = 24 
Window.Name = "PropertyTest" , X = 304 , Y = 213

15.4.1 Eigenschaften

Ausgewählte Eigenschaften und Methoden der Klasse werden in den folgenden zwei Tabellen aufgeführt und beschrieben:

EigenschaftTypeBeschreibung
Desktop IntegerGibt die Nummer (0..k) des virtuellen Desktops zurück, wo das Fenster sichtbar ist oder setzt die Nummer des Desktops, auf dem das Fenster angezeigt wird.
IconImageGibt das Fenster-Icon zurück.
IdIntegerGibt den X11-Fenster-Identifizierer zurück.
FullScreen BooleanGibt an, ob das Fenster im Vollbild-Status ist oder setzt den Vollbild-Status.
HeightIntegerGibt die Höhe des Fensters an (Pixel).
WidthIntegerGibt die Breite des Fensters an (Pixel).
MaximizedBooleanGibt True zurück, wenn das Fenster maximiert ist oder maximiert das Fenster.
MinimizedBooleanGibt True zurück, wenn das Fenster minimiert ist oder minimiert das Fenster.
NameStringGibt den Namen des Fensters an. Das ist der Fenster-Titel der Anwendung, die dieses Fenster besitzt.
StickyBooleanGibt True zurück, wenn das Fenster auf allen Desktops angezeigt wird oder zeigt das Fenster auf allen Desktops an.
VisibleStringGibt den sichtbaren Namen der Fensters zurück. Das ist der Fenster-Titel wie er vom Fenster-Manager angezeigt wird.
XIntegerGibt die x-Koordinate des Fensters zurück.
YIntegerGibt die y-Koordinate des Fensters zurück.

Tabelle 15.4.1.1: Übersicht ausgewählter Eigenschaften der Klasse DesktopWindow

15.4.2 Methoden

MethodeBeschreibung
Close() Das Fenster wird geschlossen.
GetIcon (Width As Integer, Height As Integer ) As ImageGibt das Fenster-Symbol mit der angegebenen Größe zurück.
Move ( X As Integer, Y As Integer [ , Width As Integer, Height As Integer ] )Das Fenster wird an die Position P(x,y) verschoben und optional in der Größe (Weite) und Höhe geändert.
Refresh()Stellt ein DesktopWindow-Objekt durch Abfragen der Geometrie des Fenster wieder her. Das geschieht bei einem DesktopWatcher.WindowGeometry-Ereignis automatisch.
Resize ( Width As Integer, Height As Integer )Das Fenster wird nur in der Größe (Höhe und Weite) geändert.

Tabelle 15.4.2.1: Ausgewählten Methoden der Klasse DesktopWindow

Weitere Ausführungen zur Klasse DesktopWindow (gb.desktop) finden Sie im Kapitel 15, das neben der Beschreibung der Klasse DesktopWatcher vor allem das praktische Zusammenspiel der beiden Klassen in einem Projekt demonstriert.

Download

Artikel

Download

The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k15/k15.4/start.txt · Last modified: 02.07.2018 (external edit)

Page Tools