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

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: 28.09.2023 by emma

Page Tools