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
Selected properties and methods of the class are listed and described in the following two tables:
Property | Type | Description |
---|---|---|
Desktop | Integer | Returns 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. |
Icon | Image | Returns the window icon. |
Id | Integer | Returns the X11 window identifier. |
FullScreen | Boolean | Specifies whether the window is in full screen state or sets the full screen state. |
Height | Integer | Specifies the height of the window (pixels). |
Width | Integer | Specifies the width of the window (pixels). |
Maximized | Boolean | Returns True if the window is maximized or maximizes the window. |
Minimized | Boolean | Returns True if the window is minimized or minimizes the window. |
Name | String | Specifies the name of the window. This is the window title of the application that owns this window. |
Sticky | Boolean | Returns True if the window is displayed on all desktops or displays the window on all desktops. |
Visible | String | Returns the visible name of the window. This is the window title as displayed by the window manager. |
X | Integer | Returns the x-coordinate of the window. |
Y | Integer | Returns the y-coordinate of the window. |
Table 15.4.1.1: Overview of selected properties of the DesktopWindow class
Method | Description |
---|---|
Close() | Closes the window. |
GetIcon(Width As Integer, Height As Integer) As Image | Returns 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.
Articles