Class

# DesktopWindow

<div class="rst-class">

forsearch

</div>

Popover

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

A distinct area of the user interface consisting of a frame and body that lets the user view and interact with content in an app.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                     | Type                                                             | Read-Only | Shared |
|----------------------------------------------------------|------------------------------------------------------------------|-----------|--------|
| `Backdrop<desktopwindow.backdrop>`                       | `Picture</api/graphics/picture>`                                 |           |        |
| `BackgroundColor<desktopwindow.backgroundcolor>`         | `ColorGroup</api/graphics/colorgroup>`                           |           |        |
| `Bounds<desktopwindow.bounds>`                           | `Rect</api/graphics/rect>`                                       |           |        |
| `Changed<desktopwindow.changed>`                         | `Boolean</api/data_types/boolean>`                               |           |        |
| `ControlCount<desktopwindow.controlcount>`               | `Integer</api/data_types/integer>`                               | ✓         |        |
| `DefaultLocation<desktopwindow.defaultlocation>`         | `Locations<desktopwindow.locations>`                             |           |        |
| `DockItem<desktopwindow.dockitem>`                       | `DockItem</api/macos/dockitem>`                                  | ✓         |        |
| `Focus<desktopwindow.focus>`                             | `DesktopUIControl</api/user_interface/desktop/desktopuicontrol>` |           |        |
| `FullScreen<desktopwindow.fullscreen>`                   | `Boolean</api/data_types/boolean>`                               |           |        |
| `Handle<desktopwindow.handle>`                           | `Ptr</api/data_types/additional_types/ptr>`                      | ✓         |        |
| `HasBackgroundColor<desktopwindow.hasbackgroundcolor>`   | `Boolean</api/data_types/boolean>`                               |           |        |
| `HasCloseButton<desktopwindow.hasclosebutton>`           | `Boolean</api/data_types/boolean>`                               | ✓         |        |
| `HasFullScreenButton<desktopwindow.hasfullscreenbutton>` | `Boolean</api/data_types/boolean>`                               | ✓         |        |
| `HasMaximizeButton<desktopwindow.hasmaximizebutton>`     | `Boolean</api/data_types/boolean>`                               | ✓         |        |
| `HasMinimizeButton<desktopwindow.hasminimizebutton>`     | `Boolean</api/data_types/boolean>`                               | ✓         |        |
| `HasTitleBar<desktopwindow.hastitlebar>`                 | `Boolean</api/data_types/boolean>`                               |           |        |
| `Height<desktopwindow.height>`                           | `Integer</api/data_types/integer>`                               |           |        |
| `ImplicitInstance<desktopwindow.implicitinstance>`       | `Boolean</api/data_types/boolean>`                               |           |        |
| `LastControlIndex<desktopwindow.lastcontrolindex>`       | `Integer</api/data_types/integer>`                               |           |        |
| `Left<desktopwindow.left>`                               | `Integer</api/data_types/integer>`                               |           |        |
| `MaximumHeight<desktopwindow.maximumheight>`             | `Integer</api/data_types/integer>`                               |           |        |
| `MaximumWidth<desktopwindow.maximumwidth>`               | `Integer</api/data_types/integer>`                               |           |        |
| `MenuBar<desktopwindow.menubar>`                         | `DesktopMenuBar</api/user_interface/desktop/desktopmenubar>`     |           |        |
| `MinimumHeight<desktopwindow.minimumheight>`             | `Integer</api/data_types/integer>`                               |           |        |
| `MinimumWidth<desktopwindow.minimumwidth>`               | `Integer</api/data_types/integer>`                               |           |        |
| `MouseCursor<desktopwindow.mousecursor>`                 | `MouseCursor</api/user_interface/desktop/mousecursor>`           |           |        |
| `MouseX<desktopwindow.mousex>`                           | `Integer</api/data_types/integer>`                               | ✓         |        |
| `MouseY<desktopwindow.mousey>`                           | `Integer</api/data_types/integer>`                               | ✓         |        |
| `Resizeable<desktopwindow.resizeable>`                   | `Boolean</api/data_types/boolean>`                               | ✓         |        |
| `ScaleFactor<desktopwindow.scalefactor>`                 | `Double</api/data_types/double>`                                 | ✓         |        |
| `SystemUIVisible<desktopwindow.systemuivisible>`         | `Boolean</api/data_types/boolean>`                               |           |        |
| `Title<desktopwindow.title>`                             | `String</api/data_types/string>`                                 |           |        |
| `Top<desktopwindow.top>`                                 | `Integer</api/data_types/integer>`                               |           |        |
| `Type<desktopwindow.type>`                               | `Types<desktopwindow.types>`                                     | ✓         |        |
| `Visible<desktopwindow.visible>`                         | `Boolean</api/data_types/boolean>`                               |           |        |
| `Width<desktopwindow.width>`                             | `Integer</api/data_types/integer>`                               |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                 | Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | Returns                                           | Shared |
|------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------|--------|
| `AcceptFileDrop<desktopwindow.acceptfiledrop>`       | FileType As `String</api/data_types/string>`                                                                                                                                                                                                                                                                                                                                                                                                                                         |                                                   |        |
| `AcceptPictureDrop<desktopwindow.acceptpicturedrop>` |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                   |        |
| `AcceptRawDataDrop<desktopwindow.acceptrawdatadrop>` | Type As `String</api/data_types/string>`                                                                                                                                                                                                                                                                                                                                                                                                                                             |                                                   |        |
| `AcceptTextDrop<desktopwindow.accepttextdrop>`       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                   |        |
| `AddControl<desktopwindow.addcontrol>`               | control As `DesktopUIControl</api/user_interface/desktop/desktopuicontrol>`                                                                                                                                                                                                                                                                                                                                                                                                          |                                                   |        |
| `BitmapForCaching<desktopwindow.bitmapforcaching>`   | width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                                                                            | `Picture</api/graphics/picture>`                  |        |
| `Close<desktopwindow.close>`                         |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                   |        |
| `ControlAt<desktopwindow.controlat>`                 | index As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                                                                                                                          | `Object</api/data_types/additional_types/object>` |        |
| `Controls<desktopwindow.controls>`                   |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | `Iterable</api/language/iterable>`                |        |
| `DrawInto<desktopwindow.drawinto>`                   | g As `Graphics</api/graphics/graphics>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                                            |                                                   |        |
| `FocusNext<desktopwindow.focusnext>`                 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                   |        |
| `FocusPrevious<desktopwindow.focusprevious>`         |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                   |        |
| `Hide<desktopwindow.hide>`                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                   |        |
| `Maximize<desktopwindow.maximize>`                   |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                   |        |
| `Minimize<desktopwindow.minimize>`                   |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                   |        |
| `Objects<desktopwindow.objects>`                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | `Iterable</api/language/iterable>`                |        |
| `Refresh<desktopwindow.refresh>`                     | immediately As `Boolean</api/data_types/boolean>` = `False</api/language/false>`                                                                                                                                                                                                                                                                                                                                                                                                     |                                                   |        |
|                                                      | x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`, immediately As `Boolean</api/data_types/boolean>` = `False</api/language/false>`                                                                                                                                                                                                                        |                                                   |        |
| `RemoveControl<desktopwindow.removecontrol>`         | control As `DesktopUIControl</api/user_interface/desktop/desktopuicontrol>`                                                                                                                                                                                                                                                                                                                                                                                                          |                                                   |        |
| `Restore<desktopwindow.restore>`                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                   |        |
| `SetFocus<desktopwindow.setfocus>`                   |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                   |        |
| `Show<desktopwindow.show>`                           | parent As <span class="title-ref">DesktopWindow</span> = `Nil</api/language/nil>`                                                                                                                                                                                                                                                                                                                                                                                                    |                                                   |        |
| `ShowModal<desktopwindow.showmodal>`                 | parent As <span class="title-ref">DesktopWindow</span> = `Nil</api/language/nil>`                                                                                                                                                                                                                                                                                                                                                                                                    |                                                   |        |
| `ShowPopover<desktopwindow.showpopover>`             | parentControl As `DesktopUIControl</api/user_interface/desktop/desktopuicontrol>`, displaySide As `DesktopWindow.DisplaySides<desktopwindow.displaysides>` = `DesktopWindow.DisplaySides<desktopwindow.displaysides>`.Bottom, detachable As `Boolean</api/data_types/boolean>` = `True</api/language/true>`, animated As `Boolean</api/data_types/boolean>` = `True</api/language/true>`, x As `Integer</api/data_types/integer>` = -1, y As `Integer</api/data_types/integer>` = -1 |                                                   |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                                   | Parameters                                                                                                                                                                            | Returns                            |
|------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| `Activated<desktopwindow.activated>`                                   |                                                                                                                                                                                       |                                    |
| `CancelClosing<desktopwindow.cancelclosing>`                           | appQuitting As `Boolean</api/data_types/boolean>`                                                                                                                                     | `Boolean</api/data_types/boolean>` |
| `Closing<desktopwindow.closing>`                                       |                                                                                                                                                                                       |                                    |
| `ConstructContextualMenu<desktopwindow.constructcontextualmenu>`       | Base As `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                              | `Boolean</api/data_types/boolean>` |
| `ContentsChanged<desktopwindow.contentschanged>`                       |                                                                                                                                                                                       |                                    |
| `ContextualMenuItemSelected<desktopwindow.contextualmenuitemselected>` | selectedItem As `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>`                                                                                                        | `Boolean</api/data_types/boolean>` |
| `Deactivated<desktopwindow.deactivated>`                               |                                                                                                                                                                                       |                                    |
| `DragEnter<desktopwindow.dragenter>`                                   | Obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`                                                                                   | `Boolean</api/data_types/boolean>` |
| `DragExit<desktopwindow.dragexit>`                                     | Obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`                                                                                   |                                    |
| `DragOver<desktopwindow.dragover>`                                     | x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, Obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>` | `Boolean</api/data_types/boolean>` |
| `DropObject<desktopwindow.dropobject>`                                 | Obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`                                                                                   |                                    |
| `KeyDown<desktopwindow.keydown>`                                       | Key As `String</api/data_types/string>`                                                                                                                                               | `Boolean</api/data_types/boolean>` |
| `KeyUp<desktopwindow.keyup>`                                           | Key As `String</api/data_types/string>`                                                                                                                                               |                                    |
| `Maximized<desktopwindow.maximized>`                                   |                                                                                                                                                                                       |                                    |
| `MenuBarSelected<desktopwindow.menubarselected>`                       |                                                                                                                                                                                       |                                    |
| `Minimized<desktopwindow.minimized>`                                   |                                                                                                                                                                                       |                                    |
| `MouseDown<desktopwindow.mousedown>`                                   | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      | `Boolean</api/data_types/boolean>` |
| `MouseDrag<desktopwindow.mousedrag>`                                   | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      |                                    |
| `MouseEnter<desktopwindow.mouseenter>`                                 |                                                                                                                                                                                       |                                    |
| `MouseExit<desktopwindow.mouseexit>`                                   |                                                                                                                                                                                       |                                    |
| `MouseMove<desktopwindow.mousemove>`                                   | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      |                                    |
| `MouseUp<desktopwindow.mouseup>`                                       | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      |                                    |
| `MouseWheel<desktopwindow.mousewheel>`                                 | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`, DeltaX As `Integer</api/data_types/integer>`, DeltaY As `Integer</api/data_types/integer>`          | `Boolean</api/data_types/boolean>` |
| `Moved<desktopwindow.moved>`                                           |                                                                                                                                                                                       |                                    |
| `Opening<desktopwindow.opening>`                                       |                                                                                                                                                                                       |                                    |
| `Paint<desktopwindow.paint>`                                           | g As `Graphics</api/graphics/graphics>`, areas() As `Rect</api/graphics/rect>`                                                                                                        |                                    |
| `Resized<desktopwindow.resized>`                                       |                                                                                                                                                                                       |                                    |
| `Resizing<desktopwindow.resizing>`                                     |                                                                                                                                                                                       |                                    |
| `Restored<desktopwindow.restored>`                                     |                                                                                                                                                                                       |                                    |
| `ScaleFactorChanged<desktopwindow.scalefactorchanged>`                 |                                                                                                                                                                                       |                                    |

## Enumerations

<div id="desktopwindow.displaysides">

<div class="rst-class">

forsearch

</div>

</div>

DesktopWindow.DisplaySides

### DisplaySides

> Specifies where the popover will display relative to the control its popping over.
>
> | Enum   | Description                         |
> |--------|-------------------------------------|
> | Bottom | Below the parent control.           |
> | Left   | To the left of the parent control.  |
> | Top    | Above the parent control.           |
> | Right  | To the right of the parent control. |

<div id="desktopwindow.locations">

<div class="rst-class">

forsearch

</div>

</div>

DesktopWindow.Locations

### Locations

> Specifies where the window will open.
>
> | Enum               | Description                                                                          |
> |--------------------|--------------------------------------------------------------------------------------|
> | Default            | The default placement based upon the OS. Often this is Staggered.                    |
> | ParentWindow       | Over the parent window if it opens another window.                                   |
> | MainScreen         | On the primary or main screen on a multi-screen setup.                               |
> | ParentWindowScreen | On the same screen as the parent window in a multi-screen setup.                     |
> | Staggered          | New windows open slightly offset to the top and left from previously opened windows. |

<div id="desktopwindow.types">

<div class="rst-class">

forsearch

</div>

</div>

DesktopWindow.Types

### Types

> Specifies the type of window.
>
> | Value          |
> |----------------|
> | Document       |
> | MovableModal   |
> | ModalDialog    |
> | Floating       |
> | PlainBox       |
> | ShadowedBox    |
> | Rounded        |
> | GlobalFloating |
> | Sheet          |
> | ModelessDialog |

## Property descriptions

<div id="desktopwindow.backdrop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Backdrop

**Backdrop** As `Picture</api/graphics/picture>`

> Gets or sets the picture object that will be drawn in the window's background.
>
> You should not assign a new picture to the backdrop of the window when being inside the paint event of that window. This can lead into problems like the backdrop not being painted.
>
> This example sets the backdrop to a jpg image that has been added to the Project. This is in the Opening event.
>
> ``` xojo
> Me.Backdrop = MyPicture
> ```

<div id="desktopwindow.backgroundcolor">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.BackgroundColor

**BackgroundColor** As `ColorGroup</api/graphics/colorgroup>`

> The background color for the object. The `HasBackgroundColor<desktopwindow.hasbackgroundcolor>` property, must be set to `True</api/language/true>` to have the BackgroundColor displayed.
>
> This code sets the `HasBackgroundColor<desktopwindow.hasbackgroundcolor>` property and sets the value of the BackgroundColor property:
>
> ``` xojo
> Me.HasBackgroundColor = True
> Me.BackgroundColor = New ColorGroup(&c110034)
> ' You can also assign a color value.
> ```

<div id="desktopwindow.bounds">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Bounds

**Bounds** As `Rect</api/graphics/rect>`

> Use this property to Get/Set the true bounds of a window (i.e. including frame/title decorations).
>
> On Linux the Left/Top bounds exclude the decorations due to the way window decorations are handled there.
>
> To get the bounds:
>
> ``` xojo
> Var winBounds As Rect
> winBounds = Self.Bounds
> MessageBox("Left = " + winBounds.Left.ToString)
> ```
>
> To set the bounds, do not modify the Bounds properly directly. This does not work because you will be modifying a temporary object. Instead set the bounds in your own Rect instance and assign that to bounds:
>
> ``` xojo
> Var myBounds As New Rect
> myBounds.Left = 100
> myBounds.Top = 100
> myBounds.Height = Self.Height
> myBounds.Width = Self.Width
> Self.Bounds = myBounds
> ```

<div id="desktopwindow.changed">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Changed

**Changed** As `Boolean</api/data_types/boolean>`

> Indicates whether the window has been modified. The ContentsChanged event fires when the value of this property has changed. On macOS, the window's Close button displays a dot when Changed is `True</api/language/true>`.
>
> This example is in the ContentsChanged event of the control.
>
> ``` xojo
> If Me.Changed Then
>   MessageBox("The contents have changed!")
> Else
>   MessageBox("The ContentsChanged event has not fired.")
> End If
> ```

<div id="desktopwindow.controlcount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.ControlCount

**ControlCount** As `Integer</api/data_types/integer>`

> The number of controls in the window.
>
> This property is read-only.
>
> The following example is in the Pressed event of a `DesktopButton</api/user_interface/desktop/desktopbutton>`. It displays the number of controls in the Window:
>
> ``` xojo
> MessageBox(Self.ControlCount.ToString)
> ```

<div id="desktopwindow.defaultlocation">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.DefaultLocation

**DefaultLocation** As `Locations<desktopwindow.locations>`

> If it's a Document window, this property represents the window's location at which the window will initially be placed when it opens.
>
> The `Locations<desktopwindow.locations>` enumeration contains all potential values for this property.

<div id="desktopwindow.dockitem">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.DockItem

**DockItem** As `DockItem</api/macos/dockitem>`

> Enables you to access the `DockItem</api/macos/dockitem>` class to manipulate the dock item associated with the window (macOS only).
>
> This property is read-only.
>
> The `DockItem</api/macos/dockitem>` class has two methods, UpdateNow and ResetIcon, and one property, `Graphics</api/graphics/graphics>`. Use the methods of the `Graphics</api/graphics/graphics>` class to modify the appearance of the icon. (The `Graphics</api/graphics/graphics>` property may be `Nil</api/language/nil>`; it is non-`Nil</api/language/nil>` only when a macOS window has been minimized to the dock.) The ResetIcon method resets the icon to its original state (default appearance). Since a macOS icon is intended to be scaled automatically, you should design it as a 512 x512 pixel icon and include smaller sizes. Call the UpdateNow method to redraw the icon. You can also use the `Graphics.ClearRectangle<graphics.clearrectangle>` method to start over form a blank icon. Anything you can do with a `Graphics</api/graphics/graphics>` object you are able to do with the Dock's `Graphics</api/graphics/graphics>` object (like drawing in a picture or using a Shape 2D). The Dockitem property of the `DesktopApplication</api/user_interface/desktop/desktopapplication>` class enables you to control the `DockItem</api/macos/dockitem>` for the whole application.

<div id="desktopwindow.focus">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Focus

**Focus** As `DesktopUIControl</api/user_interface/desktop/desktopuicontrol>`

> Gets or sets the `DesktopUIControl</api/user_interface/desktop/desktopuicontrol>` in the window that has the focus. If no control has the focus, this property is `Nil</api/language/nil>`.
>
> The following example reports on the control in the `DesktopContainer</api/user_interface/desktop/desktopcontainer>` that has the focus.
>
> ``` xojo
> MessageBox(ContainerControl11.Focus.Name)
> ```

<div id="desktopwindow.fullscreen">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.FullScreen

**FullScreen** As `Boolean</api/data_types/boolean>`

> When set to `True</api/language/true>`, the window resizes itself to cover the entire screen.
>
> The values of the Left, Top, Width, and Height properties are adjusted to reflect the window's new position. They cannot be changed as long as FullScreen is `True</api/language/true>`. In the case of multiple monitors, the window resizes to fit the monitor which contains the greatest portion of the window.
>
> FullScreen defaults to `False</api/language/false>`.
>
> On macOS, you can instead set `HasFullScreenButton<desktopwindow.hasfullscreenbutton>` to `True</api/language/true>` to let the user enable the macOS full screen mode.

<div id="desktopwindow.handle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Handle

**Handle** As `Ptr</api/data_types/additional_types/ptr>`

> Returns a handle to the window. Use this instead of the deprecated MacWindowPtr and WinHWND.
>
> This property is read-only.
>
> When interfacing with Cocoa APIs using `Declares</api/language/declare>` Window.Handle always gives a NSWindow or NSPanel.

<div id="desktopwindow.hasbackgroundcolor">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.HasBackgroundColor

**HasBackgroundColor** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the background color of the window is set to the value of the `BackgroundColor<desktopwindow.backgroundcolor>` property.
>
> This property must be set in order for the value of the `BackgroundColor<desktopwindow.backgroundcolor>` property to be applied to the window.
>
> This example sets the HasBackgroundColor property and sets the value of the BackgroundColor property.
>
> ``` xojo
> Me.HasBackgroundColor = True
> Me.BackgroundColor = &c110034
> ```

<div id="desktopwindow.hasclosebutton">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.HasCloseButton

**HasCloseButton** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the window will include a Close button in its Title Bar.
>
> This property is read-only.
>
> On macOS, if the `ContentsChanged<desktopwindow.contentschanged>` property is `True</api/language/true>`, then the close button will display a dot, which is used to indicate there are unsaved changes in the window.
>
> MacOS does not display close buttons on Movable Modal windows.

<div id="desktopwindow.hasfullscreenbutton">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.HasFullScreenButton

**HasFullScreenButton** As `Boolean</api/data_types/boolean>`

> When set to `True</api/language/true>`, the window control to enable macOS full screen mode is displayed.
>
> This property is read-only.
>
> This property can only be changed at design-time.
>
> Clicking the control enables the macOS native full screen mode. This property has no effect on Windows or Linux.
>
> In order to test if the user is running in the native full screen mode you should check both full screen properties:
>
> ``` xojo
> If Self.HasFullScreenButton And Self.FullScreen Then
>   ' User is in native full screen mode
> End If
> ```
>
> When HasFullScreenButton is `False</api/language/false>`, setting `FullScreen<desktopwindow.fullscreen>` to `True</api/language/true>` cause the Window to fill the screen although not using the native full screen mode so the behavior will be different.

<div id="desktopwindow.hasmaximizebutton">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.HasMaximizeButton

**HasMaximizeButton** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the window has an enabled Maximize button in its Title bar.
>
> This property is read-only.
>
> You can only change this setting while in the Window Layout Editor.
>
> Starting with macOS 10.11 (El Capitan), the Maximize button is treated as a full screen button. You do not have to specifically set `HasFullScreenButton<desktopwindow.hasfullscreenbutton>` to `True</api/language/true>`. In order for the user to maximize a window rather than put it into Full Screen Mode, they should Option-Click on the Maximize button or double-click the title bar.

<div id="desktopwindow.hasminimizebutton">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.HasMinimizeButton

**HasMinimizeButton** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the window has a Minimize button in its Title bar. The default is `True</api/language/true>`.
>
> This property is read-only.
>
> You can only change this setting while in the Window Layout Editor.

<div id="desktopwindow.hastitlebar">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.HasTitlebar

**HasTitleBar** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the window has a title bar. The default is `True</api/language/true>`.
>
> On macOS, setting this property to `False</api/language/false>` will also hide the window's toolbar if it has one.
>
> <div class="tip">
>
> <div class="title">
>
> Tip
>
> </div>
>
> On Linux, it is recommended that you set this property in the Inspector rather than via code at runtime because removing it makes the window no longer resizable which can cause window sizing issues.
>
> </div>

<div id="desktopwindow.height">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Height

**Height** As `Integer</api/data_types/integer>`

> The height of the content region of the window in points.
>
> ``` xojo
> Me.Height = 100
> ```

<div id="desktopwindow.implicitinstance">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.ImplicitInstance

**ImplicitInstance** As `Boolean</api/data_types/boolean>`

> When `True</api/language/true>`, an instance of this window will be opened automatically upon application launch.
>
> This is a **design-time-only property** and thus is not accessible via code.

<div id="desktopwindow.lastcontrolindex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.LastControlIndex

**LastControlIndex** As `Integer</api/data_types/integer>`

> The index of the last `DesktopControl</api/user_interface/desktop/desktopcontrol>` on the <span class="title-ref">DesktopWindow</span>.

<div id="desktopwindow.left">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Left

**Left** As `Integer</api/data_types/integer>`

> The distance (in points) between the left edge of the screen and the left edge of the content area of the window.
>
> The left frame of the window is taken into account.
>
> ``` xojo
> Me.Left = 50
> ```

<div id="desktopwindow.maximumheight">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MaximumHeight

**MaximumHeight** As `Integer</api/data_types/integer>`

> The maximum height (in points) to which the window can be resized.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> On Windows, when the user maximumizes a window it does not respect this property.
>
> </div>

<div id="desktopwindow.maximumwidth">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MaximumWidth

**MaximumWidth** As `Integer</api/data_types/integer>`

> The maximum width (in points) to which the window can be resized.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> On Windows, when the user maximumizes a window it does not respect this property.
>
> </div>

<div id="desktopwindow.menubar">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MenuBar

**MenuBar** As `DesktopMenuBar</api/user_interface/desktop/desktopmenubar>`

> The menubar that is associated with the window.
>
> This is the `DesktopMenuBar</api/user_interface/desktop/desktopmenubar>` to use with the window. Typically this is the MenuBar that was added to the project by default, but it can be any MenuBar in your project.
>
> When the window is active, this MenuBar is displayed.
>
> On macOS, if no MenuBar is assigned to the window, `DesktopApplication.MenuBar<desktopapplication.menubar>` is used. To hide the MenuBar, set the MenuBar property to None (in the Inspector) or Nil (in code) for both the window and the Application.
>
> On Microsoft Windows and Linux, a window can have a MenuBar just below its title bar. The MenuBar assigned to the window is used as the window MenuBar. If the window does not have a MenuBar specified (i.e. it is set to None in the Inspector or Nil in code), then the window will not display a MenuBar.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> For MDI applications, the MDI window uses `DesktopApplication.MenuBar<desktopapplication.menubar>` as its MenuBar. Individual document windows cannot have a MenuBar (a Windows limitation). However, floating windows can have a MenuBar and these windows use the MenuBar specified in the window.
>
> </div>
>
> <div class="warning">
>
> <div class="title">
>
> Warning
>
> </div>
>
> On Windows, assigning a Menubar to a <span class="title-ref">DesktopWindow</span> whose `Type<desktopwindow.type>` is Shadow will raise an `UnsupportedOperationException</api/exceptions/unsupportedoperationexception>`.
>
> </div>
>
> This code in a DesktopButton Pressed event toggles the MenuBar on and off:
>
> ``` xojo
> If Self.MenuBar <> Nil Then
>   #If TargetMacOS Then
>     App.MenuBar = Nil
>   #Endif
>   Self.MenuBar = Nil
> Else
>   #If TargetMacOS Then
>     App.MenuBar = MainMenuBar
>   #Endif
>
>   Self.MenuBar = MainMenuBar
> End If
> ```

<div id="desktopwindow.minimumheight">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MinimumHeight

**MinimumHeight** As `Integer</api/data_types/integer>`

> The minimum height to which the window can be resized.

<div id="desktopwindow.minimumwidth">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MinimumWidth

**MinimumWidth** As `Integer</api/data_types/integer>`

> The minimum width to which the window can be resized.

<div id="desktopwindow.mousecursor">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MouseCursor

**MouseCursor** As `MouseCursor</api/user_interface/desktop/mousecursor>`

> The cursor to be displayed while the mouse is within the window and the `DesktopApplication</api/user_interface/desktop/desktopapplication>` class's MouseCursor property is `Nil</api/language/nil>`.
>
> If the `DesktopApplication</api/user_interface/desktop/desktopapplication>` class MouseCursor is not `Nil</api/language/nil>`, non-Nil MouseCursors belonging to any windows or `Controls</api/user_interface/desktop/desktopcontrol>` are ignored. If the window's MouseCursor property is not `Nil</api/language/nil>`, the MouseCursor properties of any `Controls</api/user_interface/desktop/desktopcontrol>` are ignored. You can use the cursors in the `Cursors</api/user_interface/desktop/cursors>` module to set the MouseCursor for the window.
>
> This line sets the default cursor to the finger pointer.
>
> ``` xojo
> Me.MouseCursor = System.Cursors.FingerPointer
> ```

<div id="desktopwindow.mousex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MouseX

**MouseX** As `Integer</api/data_types/integer>`

> The X coordinate of the mouse (points). Measured from the top-left corner of the window.
>
> This property is read-only.

<div id="desktopwindow.mousey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MouseY

**MouseY** As `Integer</api/data_types/integer>`

> The Y coordinate of the mouse (points). Measured from the top-left corner of the window.
>
> This property is read-only.

<div id="desktopwindow.resizeable">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Resizeable

**Resizeable** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the window is resizeable. The default is `True</api/language/true>`.
>
> This property is read-only.
>
> You can only change this setting while in the Window Layout Editor.

<div id="desktopwindow.scalefactor">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.ScaleFactor

**ScaleFactor** As `Double</api/data_types/double>`

> The scale factor used when converting user space coordinates to backing store coordinates for this Window.
>
> This property is read-only.

<div id="desktopwindow.systemuivisible">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.SystemUIVisible

**SystemUIVisible** As `Boolean</api/data_types/boolean>`

> When set to `False</api/language/false>`, hides system-wide UI, such as the Dock on macOS or the Start menu and taskbar on Windows. Defaults to `True</api/language/true>`.
>
> The behavior of this properties varies by OS. This is the behavior on current OS's (macOS Mojave, Windows 10, Linux Mint):
>
> - macOS: When `False</api/language/false>` (or OFF), the Dock and main menu bar are hidden when the window is frontmost.
> - Windows: When `False</api/language/false>` (or OFF), the taskbar (including "Start" button) is hidden, regardless of whether your app is frontmost.
> - Linux Mint: When `False</api/language/false>` (or OFF), the window menu bar is hidden (other distributions may have different behavior).

<div id="desktopwindow.title">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Title

**Title** As `String</api/data_types/string>`

> The text in the window's Title bar.

<div id="desktopwindow.top">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Top

**Top** As `Integer</api/data_types/integer>`

> The distance (in pixels) between the top edge of the screen and the top edge of the content region of the window.
>
> The Top value refers to the topmost part of the window content region, which is the area starting below the Window Title Bar.
>
> Setting Top = 0 moves the top of the windows content area to the top of the screen. On macOS, this puts the window behind the main menu bar that appears at the top of the screen. To position a window directly below the main menu bar, you should use `DesktopDisplay.AvailableTop<desktopdisplay.availabletop>` to get the topmost position after the menu bar and then use `Bounds<desktopwindow.bounds>` to position the window.

<div id="desktopwindow.type">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Type

**Type** As `Types<desktopwindow.types>`

> The window type. Set the desired Type in the Inspector.
>
> This property is read-only.
>
> Use the `Types<desktopwindow.types>` enumeration to determine the value of this property.
>
> The various frame types are covered in the `Desktop Windows</topics/user_interface/desktop/windows/window_types>` topic.

<div class="warning">

<div class="title">

Warning

</div>

Opening a `Document<desktopwindow.types>` type window from a `MoveableModal<desktopwindow.types>` type window is not supported. Doing so will result in unpredictable behavior.

</div>

<div id="desktopwindow.visible">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Visible

**Visible** As `Boolean</api/data_types/boolean>`

> Controls the visibility of the window.
>
> If `True</api/language/true>`, the window will be visible when it is opened. After it is opened, setting Visible to `False</api/language/false>` is equivalent to calling the Hide method. Or, if the window not initially shown, setting Visible to `True</api/language/true>` is equivalent to calling the Show method.

<div id="desktopwindow.width">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Width

**Width** As `Integer</api/data_types/integer>`

> The width of the content region of the window.
>
> The left and right window frames are taken into account.

## Method descriptions

<div id="desktopwindow.acceptfiledrop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.AcceptFileDrop

**AcceptFileDrop**(FileType As `String</api/data_types/string>`)

> Permits documents of type *FileType* to be dropped on the window.
>
> *FileType* must be a file type you specified via the `FileType</api/files/filetype>` class or the File Type Sets Editor. It works correctly even if you have multiple file types defined with the same File type code, and you don't specifically call AcceptFileDrop for the first such type.

<div id="desktopwindow.acceptpicturedrop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.AcceptPictureDrop

**AcceptPictureDrop**

> Permits pictures to be dropped on the window.

<div id="desktopwindow.acceptrawdatadrop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.AcceptRawDataDrop

**AcceptRawDataDrop**(Type As `String</api/data_types/string>`)

> Permits data (of the type specified) to be dropped on the window. *Type* is a four-character resource code, e.g., 'snd ' or 'TEXT', or a UTI such as 'public.data' or 'public.jpeg'.

<div id="desktopwindow.accepttextdrop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.AcceptTextDrop

**AcceptTextDrop**

> Permits text to be dropped on the window.

<div id="desktopwindow.addcontrol">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.AddControl

**AddControl**(control As `DesktopUIControl</api/user_interface/desktop/desktopuicontrol>`)

> Adds the control passed to the layout.
>
> To remove a control, call its `Close<desktopcontrol.close>` method.
>
> <div class="warning">
>
> <div class="title">
>
> Warning
>
> </div>
>
> Controls created dynamically (to be added to the window) will not have the default values controls are given when created in the Layout Editor. You will need to supply all default values. For example, with a `DesktopListBox</api/user_interface/desktop/desktoplistbox>`, if your code doesn't specify the `DefaultRowHeight<desktoplistbox.defaultrowheight>`, it will be zero, which means the rows will not appear.
>
> </div>

<div id="desktopwindow.bitmapforcaching">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.BitmapForCaching

**BitmapForCaching**(width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`) As `Picture</api/graphics/picture>`

> Returns a bitmap that is configured correctly for using as a cache for content to be drawn to this Window. This image supports Alpha Channels (not masked images).
>
> Use this method instead of "New Picture" in order to get a Picture image that is suitable for HiDPI displays.
>
> Raises exceptions in the following cases:
>
> - `InvalidArgumentException</api/exceptions/invalidargumentexception>` if width, height, or scale are less than or equal to zero
> - `OutOfMemoryException</api/exceptions/outofmemoryexception>` if the picture could not be allocated
>
> If you need to support images with masks AND images that use alpha channels code like the following will let you handle both cases for HiDPI displays
>
> ``` xojo
> Public Function BitmapForCaching(Extends g As Graphics, width As Integer = -1, height As Integer = -1, withMask As Boolean = False) As Picture
>   #Pragma BackgroundTasks False
>   If width = -1 Then width = g.Width
>   If height = -1 Then height = g.Height
>
>   If width <= 0 Then width = 1
>   If height <= 0 Then height = 1
>
>   #If TargetLinux Then
>     If withMask Then
>       Return New Picture(width, height, 32)
>     Else
>       Return New Picture(width, height)
>     End If
>   #Else
>     Var pic As Picture
>     If withMask Then
>       pic = New Picture(width * g.ScaleX, height * g.ScaleY, 32)
>     Else
>       pic = New Picture(width * g.ScaleX, height * g.ScaleY)
>     End If
>     ' Set the resolutions
>     pic.HorizontalResolution = 72 * g.ScaleX
>     pic.VerticalResolution = 72 * g.ScaleY
>
>     ' Make sure the two graphics object scales match the reference graphics object
>     Var gScaleX As Double = g.ScaleX
>     Var gScaleY As Double = g.ScaleY
>     pic.Graphics.ScaleX = gScaleX
>     pic.Graphics.ScaleY = gScaleY
>     If withMask Then
>       pic.Mask.Graphics.ScaleX = gScaleX
>       pic.Mask.Graphics.ScaleY = gScaleY
>     End If
>     Return pic
>   #Endif
> End Function
> ```

<div id="desktopwindow.close">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Close

**Close**

> Closes the window. Once closed, a window cannot be refreshed or redrawn. Calling Close triggers the CancelClosing event.

<div id="desktopwindow.controlat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.ControlAt

**ControlAt**(index As `Integer</api/data_types/integer>`) As `Object</api/data_types/additional_types/object>`

> The zero-based way to lookup controls in the window.
>
> All controls on the window are returned as an `Object</api/data_types/additional_types/object>` base type. You can use the IsA operator to check the specific type to see if the control is a DesktopButton, DesktopLabel, etc.
>
> This example is in the Pressed event of a `DesktopButton</api/user_interface/desktop/desktopbutton>` and displays the name of the first control in Window:
>
> ``` xojo
> MessageBox(Self.ControlAt(0).Name)
> ```
>
> Loop through all the controls on a Window and disable only the TextFields:
>
> ``` xojo
> Var c As Object
> For i As Integer = 0 To Self.ControlCount - 1
>   c = Window.ControlAt(i)
>   If c IsA DesktopTextField Then
>     DesktopTextField(c).Enabled = False
>   End If
> Next
> ```
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> The order in which controls are indexed is based on their layering on the window. You can change this in the `Layout Editor</getting_started/using_the_ide/layout_editor>` using the `Order Front, Order Forward, Order Back, and Order Backwards</getting_started/using_the_ide/layout_editor/ordering>` buttons. If you need the tab order, use the `TabIndex<desktopuicontrol.tabindex>` property.
>
> </div>

<div id="desktopwindow.controls">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Controls

**Controls** As `Iterable</api/language/iterable>`

> Used to iterate through the controls on a window.
>
> All controls on the window are returned as a the `DesktopControl</api/user_interface/desktop/desktopcontrol>` base type. You can use the IsA operator to check the specific type to see if the control is a button, label, etc.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> This does not include non-control object instances. For that, use the `Objects<desktopwindow.objects>` method.
>
> </div>
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> The iterator returns an Object rather than a DesktopControl. This allows it to return DesktopContainers for example that are not DesktopControls.
>
> </div>
>
> Loop through all the controls on a Window and disable only the textfields:
>
> ``` xojo
> For Each c As Object In Self.Controls
>   If c IsA DesktopTextField Then
>     DesktopTextField(c).Enabled = False
>   End If
> Next
> ```

<div id="desktopwindow.drawinto">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.DrawInto

**DrawInto**(g As `Graphics</api/graphics/graphics>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`)

> Draws the contents of the window into *g* at the coordinates specified by the *x* and *y* parameters passed.

<div id="desktopwindow.focusnext">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.FocusNext

**FocusNext**

> Changes the focus to the next control in the Tab Order.

<div id="desktopwindow.focusprevious">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.FocusPrevious

**FocusPrevious**

> Changes the focus to the previous control in the Tab Order.

<div id="desktopwindow.hide">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Hide

**Hide**

> Makes the window invisible.

<div id="desktopwindow.maximize">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Maximize

**Maximize**

> Maximizes the window if it is not already maximized and calls the `Maximized<desktopwindow.maximized>` event. If the window was already maximized when you call this method, then it is restored to its prior state and calls the `Restored<desktopwindow.restored>` event.
>
> If the window is not visible when Maximize is called, it becomes visible.

<div id="desktopwindow.minimize">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Minimize

**Minimize**

> Minimizes the window and calls the `Minimize<desktopwindow.minimize>` event handler.

<div id="desktopwindow.objects">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Objects

**Objects** As `Iterable</api/language/iterable>`

> Allows you to iterate through all the non-control object instances on the window.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> This does not include controls. For that, use the `Controls<desktopwindow.controls>` method.
>
> </div>

<div id="desktopwindow.refresh">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Refresh

**Refresh**(immediately As `Boolean</api/data_types/boolean>` = `False</api/language/false>`)

**Refresh**(x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`, immediately As `Boolean</api/data_types/boolean>` = `False</api/language/false>`)

> Redraws the entire window passed the next time the OS redraws the window or immediately if `True</api/language/true>` is passed.

<div id="desktopwindow.removecontrol">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.RemoveControl

**RemoveControl**(control As `DesktopUIControl</api/user_interface/desktop/desktopuicontrol>`)

> Removes the *control* from the <span class="title-ref">DesktopWindow</span>.

<div id="desktopwindow.restore">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Restore

**Restore**

> Restores a minimized or maximized window to its previous size.

<div id="desktopwindow.setfocus">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.SetFocus

**SetFocus**

> Sets the focus to the window, leaving no control with the focus. If the window is in the process of closing, SetFocus will do nothing.
>
> Use the SetFocus method of the `DesktopUIControl</api/user_interface/desktop/desktopuicontrol>` class to set the focus to a particular control in the window.

<div id="desktopwindow.show">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Show

**Show**(parent As <span class="title-ref">DesktopWindow</span> = `Nil</api/language/nil>`)

> Forces the window to immediately become visible rather than wait until the application is idle.
>
> Passing the optional *parent* parameter allows you to specify the parent window and thus show a sheet-style window non-modally on macOS.
>
> Calling Show immediately brings the window to the front.

<div id="desktopwindow.showmodal">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.ShowModal

**ShowModal**(parent As <span class="title-ref">DesktopWindow</span> = `Nil</api/language/nil>`)

> Displays the window and causes the current method to stop executing until the window closes or becomes invisible.
>
> If the window is a Document window it is shown as a normal Document window. It becomes the frontmost window but it is not modal. You must use a modal window Frame type to force the window into a modal state.
>
> If a *parent* Window is passed, the window being displayed will be modal to the parent window on macOS.
>
> <div class="warning">
>
> <div class="title">
>
> Warning
>
> </div>
>
> Opening a `Document<desktopwindow.types>` type window from a `MoveableModal<desktopwindow.types>` type window is not supported. Doing so will result in unpredictable behavior.
>
> </div>

<div id="desktopwindow.showpopover">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.ShowPopover

**ShowPopover**(parentControl As `DesktopUIControl</api/user_interface/desktop/desktopuicontrol>`, displaySide As `DesktopWindow.DisplaySides<desktopwindow.displaysides>` = `DesktopWindow.DisplaySides<desktopwindow.displaysides>`.Bottom, detachable As `Boolean</api/data_types/boolean>` = `True</api/language/true>`, animated As `Boolean</api/data_types/boolean>` = `True</api/language/true>`, x As `Integer</api/data_types/integer>` = -1, y As `Integer</api/data_types/integer>` = -1)

> Displays the window as a popover next to the *parentControl* based upon the parameters passed. When provided, the optional *x* and *y* values passed display the popover at that offset relative to the upper-left corner of the parent control.
>
> The *animated* parameter is supported for Linux and macOS only.
>
> Behind the scenes, a popover is a window. Therefore once the user clicks away from it, the popover is closed by the OS and thus window used is `Nil</api/language/nil>`.
>
> To make sure your popover displays in front of any global floating windows, set the `Type<desktopwindow.type>` property to `GlobalFloating<desktopwindow.types>`.
>
> This example from a `button's Pressed</api/user_interface/desktop/desktopbutton>` event displays the window named *MyPopover* below (the default) the button:
>
> ``` xojo
> Var c As New MyPopover
> c.ShowPopover(Me)
> ```
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> The ability to detach a popover is only supported on macOS.
>
> </div>
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> On Linux, popovers require GTK 3.22 or later.
>
> </div>
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> On Windows, ShowPopover does not support window types `ModalDialog<desktopwindow.types>`, `MoveableModal<desktopwindow.types>` and `SheetWindow<desktopwindow.types>`. An `UnsupportedOperationException</api/exceptions/unsupportedoperationexception>` will be raised.
>
> </div>

## Event descriptions

<div id="desktopwindow.activated">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Activated

**Activated**

> The window has been activated.
>
> In an app with multiple windows, the Activated event fires each time the window becomes the frontmost. This includes when it opens. When the window first opens, the Opening event fires prior to the Activated event. Subsequent activations fire the Activated event but not the Opening event.

<div id="desktopwindow.cancelclosing">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.CancelClosing

**CancelClosing**(appQuitting As `Boolean</api/data_types/boolean>`) As `Boolean</api/data_types/boolean>`

> The window is about to be closed by the user clicking the close button, by calling the `Quit</api/language/quit>` or `Close<desktopwindow.close>` methods.
>
> When the app is quitting, `CancelClosing<desktopwindow.cancelclosing>` and `Closing<desktopwindow.closing>` are called as a pair for each open window. `Closing<desktopwindow.closing>` will be called after `CancelClosing<desktopwindow.cancelclosing>` executes, assuming that the close wasn't canceled by the user.
>
> `Return</api/language/return>` `True</api/language/true>` to prevent the window (and in the case of the `Quit</api/language/quit>` method, other open windows) from closing. The parameter *appQuitting* is `True</api/language/true>` when the window is being closed because the whole app is quitting and `False</api/language/false>` when only the window is being closed.

<div id="desktopwindow.closing">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Closing

**Closing**

> The Window is about to close. You cannot cancel the closing at this time. If you need to decide or interact with the user to make sure that the Window should be closed, use `CancelClosing<desktopwindow.cancelclosing>` event instead which is called before `Closing<desktopwindow.closing>`.

<div id="desktopwindow.constructcontextualmenu">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.ConstructContextualMenu

**ConstructContextualMenu**(Base As `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

> Fires whenever it is appropriate to display a contextual menu for the window.
>
> This is the recommended way to handle contextual menus because this event figures out whether the user has requested the contextual menu, regardless of how he did it. Returns a `Boolean</api/data_types/boolean>`. *Base* is analogous to the menu bar for the contextual menu. Any items you add to *Base* will be shown as menu items. If you return `False</api/language/false>`, the event is passed up the parent hierarchy. If you return `True</api/language/true>`, the contextual menu is displayed. The parameters *x* and *y* are the mouse locations. If the event was fired because of a non-mouse event, then *x* and *y* are both set to -1. See the example of a contextual menu in the examples for the `DesktopUIControl</api/user_interface/desktop/desktopuicontrol>` class.
>
> The following ConstructContextualMenu event handler builds a menu with three menu items plus a submenu with three additional menu items.
>
> ``` xojo
> ' Add some items
> base.AddMenu(New DesktopMenuItem("Test 1" ))
> base.AddMenu(New DesktopMenuItem("Test 2"))
> base.AddMenu(New DesktopMenuItem("Test 3"))
>
> ' Add a Separator
> base.AddMenu(New DesktopMenuItem(MenuItem.TextSeparator))
>
> ' Add a sub menu
> Var submenu As New DesktopMenuItem("SubMenu")
> submenu.AddMenu(New DesktopMenuItem("SubMenu Test 1"))
> submenu.AddMenu(New DesktopMenuItem("SubMenu Test 2"))
> submenu.AddMenu(New DesktopMenuItem("SubMenu Test 3"))
> base.AddMenu(submenu)
>
> Return True
> ```

<div id="desktopwindow.contentschanged">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.ContentsChanged

**ContentsChanged**

> Fires when the value of the `Changed<desktopwindow.changed>` property has changed. Changing the value of the `Changed<desktopwindow.changed>` property triggers this event.

<div id="desktopwindow.contextualmenuitemselected">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.ContextualMenuItemSelected

**ContextualMenuItemSelected**(selectedItem As `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>`) As `Boolean</api/data_types/boolean>`

> Fires when a contextual `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>` *selectedItem* was selected but the `MenuItemSelected<desktopmenuitem.menuitemselected>` event and the MenuHandler for the `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>` did not handle the menu selection.
>
> This event gives you a chance to handle the menu selection by inspecting the menuitem's `Text<desktopmenuitem.text>` or `Tag<desktopmenuitem.tag>` properties to see which item was selected. Use this in conjunction with `ConstructContextualMenu<desktopwindow.constructcontextualmenu>` if you have not specified the `MenuItemSelected<desktopmenuitem.menuitemselected>` event or the Menu Handler for the items on the contextual menu.
>
> The following code in a ConstructContextualMenu event builds a simple contextual menu. The parameter *Base* as `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>` is passed in as a parameter.
>
> ``` xojo
> base.AddMenu(New DesktopMenuItem("Import"))
> base.AddMenu(New DesktopMenuItem("Export"))
> Return True  ' display the contextual menu
> ```
>
> The following `Select</api/language/select_case>` statement in the ContextualMenuItemSelected event handler inspects the selected menu item, which is passed in as the *selectedItem* as `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>` parameter.
>
> ``` xojo
> Select Case selectedItem.Text
> Case "Import"
>   MessageBox("You chose Import")
> Case "Export"
>   MessageBox("You chose export")
> End Select
>
> Return True
> ```

<div id="desktopwindow.deactivated">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Deactivated

**Deactivated**

> The window has been deactivated. For example, a window belonging to another app has been activated.

<div id="desktopwindow.dragenter">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.DragEnter

**DragEnter**(Obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`) As `Boolean</api/data_types/boolean>`

> Fired when the `DragItem</api/user_interface/desktop/dragitem>` enters the <span class="title-ref">DesktopWindow</span>. Return `True</api/language/true>` from this event to prevent the drop from occurring.
>
> The *Action* parameter specifies the type drag action (default, copy, move or link).

<div id="desktopwindow.dragexit">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.DragExit

**DragExit**(Obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`)

> Fires when the `DragItem</api/user_interface/desktop/dragitem>` exits the <span class="title-ref">DesktopWindow</span>.
>
> The *Action* parameter specifies the type of drag action (default, copy, move or link).

<div id="desktopwindow.dragover">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.DragOver

**DragOver**(x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, Obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`) As `Boolean</api/data_types/boolean>`

> Fires when the `DragItem</api/user_interface/desktop/dragitem>` is over the <span class="title-ref">DesktopWindow</span>.
>
> The coordinates *x* and *y* are relative to the <span class="title-ref">DesktopWindow</span>. Returns a `Boolean</api/data_types/boolean>`. Return `True</api/language/true>` from this event to prevent the drop from occurring.
>
> The *Action* parameter specifies the type of drag action (default, copy, move or link).

<div id="desktopwindow.dropobject">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.DropObject

**DropObject**(Obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`)

> The item represented by *Obj* has been dropped on the window.
>
> The *Action* parameter specifies the type of drag action (default, copy, move or link).

<div id="desktopwindow.keydown">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.KeyDown

**KeyDown**(Key As `String</api/data_types/string>`) As `Boolean</api/data_types/boolean>`

> The passed *Key* has been pressed and not handled by an object in the window. For example, The tab key is never sent to any control. It is instead handled by the window itself. If the window has no controls that can receive the focus, any keys that are pressed will generate KeyDown events for the window. This event handler is passed a parameter that tells you which key was pressed. Returns a `Boolean</api/data_types/boolean>`. Returning `True</api/language/true>` means that no further processing is to be done with the Key, although the KeyUp event is still called.
>
> The following example scrolls a picture. The picture has been added to the project. The properties *XScroll* and *YScroll* have been added to the window to hold the amounts the picture has been scrolled.
>
> A convenient way to scroll a picture is with the four arrow keys. To do this, you place code in the KeyDown event handler of the window. This event receives each keystroke. Your code can test whether any of the arrow keys have been pressed and then take the appropriate action. For example, this code in the KeyDown event of the window scrolls the picture 8 pixels at a time:
>
> ``` xojo
> Select Case Key.Asc
> Case 31 ' down arrow
>   YScroll = YScroll - 8
>   Canvas1.Scroll(0, -8)
>   Return True
> Case 29 ' Right arrow
>   XScroll = XScroll - 8
>   Canvas1.Scroll(-8, 0)
>   Return True
> Case 30 ' up arrow
>   YScroll = YScroll + 8
>   Canvas1.Scroll(0, 8)
>   Return True
> Case 28 ' Left arrow
>   XScroll = XScroll + 8
>   Canvas1.Scroll(8, 0)
>   Return True
> End Select
> ```
>
> The Paint event of the Canvas has the line of code that draws the picture:
>
> ``` xojo
> g.DrawPicture(MyPicture, XScroll, YScroll)
> ```

<div id="desktopwindow.keyup">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.KeyUp

**KeyUp**(Key As `String</api/data_types/string>`)

> Fires when the passed *Key* is released and no other object on the window has captured the event. It is not guaranteed to be the same key that received the `KeyDown<desktopwindow.keydown>` event.

<div id="desktopwindow.maximized">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Maximized

**Maximized**

> The window has been maximized.
>
> This event handler is called when the window is maximized.
>
> This can occur when the user selects one of the window buttons or menu commands for the action. The event handler may also be called using one of the following methods, depending on the state of the window:
>
> - `Maximize<desktopwindow.maximize>`
> - `Minimize<desktopwindow.minimize>`
> - `Restore<desktopwindow.restore>`

<div id="desktopwindow.menubarselected">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MenuBarSelected

**MenuBarSelected**

> The user has clicked in the menu bar or pressed a keyboard shortcut assigned to one of the menu items.
>
> Use this event handler to determine whether conditions are right to enable the menu items.

<div id="desktopwindow.minimized">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Minimized

**Minimized**

> The window has been minimized.
>
> This event is called when the `Minimize<desktopwindow.minimize>` method is called or when the user choose to minimize the window using the window buttons or menu item.
>
> A minimized window is still returned by the `DesktopApplication.WindowAt<desktopapplication.windowat>` method and it is possible that it is the frontmost (0 position) window.

<div id="desktopwindow.mousedown">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MouseDown

**MouseDown**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

> The mouse button has been pressed inside the window at the *x*, *y* local coordinates passed. `Return</api/language/return>` `True</api/language/true>` if you are going to handle the mouseDown.

<div id="desktopwindow.mousedrag">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MouseDrag

**MouseDrag**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`)

> The mouse button was pressed inside the window and moved (dragged) at the location local to the window passed in to *x*, *y*. The user has moved the mouse inside the window (but not over a control) while the mouse button is held down. This event handler receives parameters that indicate where the mouse is in local window coordinates. This event will not occur unless you return `True</api/language/true>` in the MouseDown event.

<div id="desktopwindow.mouseenter">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MouseEnter

**MouseEnter**

> The user has moved the mouse inside the window from a location outside the window.

<div id="desktopwindow.mouseexit">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MouseExit

**MouseExit**

> The user has moved the mouse outside the window from a location inside the window.

<div id="desktopwindow.mousemove">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MouseMove

**MouseMove**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`)

> The user has moved the mouse inside the window.
>
> This event handler receives parameters that indicate where the mouse is in local window coordinates. The mouse has moved within the window to the *x*, *y* local coordinates passed.

<div id="desktopwindow.mouseup">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MouseUp

**MouseUp**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`)

> The mouse button has been released. This event will not occur unless you return `True</api/language/true>` in the MouseDown event handler. The idea behind this is that if the mouse was never down, it can't be up. This event handler receives parameters *x* and *y* that indicate where the mouse was released in local window coordinates.

<div id="desktopwindow.mousewheel">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.MouseWheel

**MouseWheel**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`, DeltaX As `Integer</api/data_types/integer>`, DeltaY As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

> The mouse wheel has been moved.
>
> The parameters *X* and *Y* are the mouse coordinates relative to the control that has received the event. The parameters *DeltaX* and *DeltaY* hold the number of scroll lines the wheel has been moved horizontally and vertically, as defined by the operating system. *DeltaX* is positive when the user scrolls right and negative when scrolling to the left. *DeltaY* is positive when the user scrolls down and negative when scrolling up. Returns a `Boolean</api/data_types/boolean>`. Return `True</api/language/true>` to prevent the event from propagating further.

<div id="desktopwindow.moved">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Moved

**Moved**

> The window has been moved by the user or by code that changes the window's Left or Top properties.

<div id="desktopwindow.opening">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Opening

**Opening**

> The window is opening but hasn't been displayed yet. Controls also receive Opening events. A window receives its Opening event after all of the controls have received their Opening events.
>
> You should use the Opening event instead of the Constructor for initialization.
>
> After the window opens and becomes the active window, the Activated event is called.

<div id="desktopwindow.paint">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Paint

**Paint**(g As `Graphics</api/graphics/graphics>`, areas() As `Rect</api/graphics/rect>`)

> Some portion of the window needs to be redrawn either because the window is opening or it has been exposed when a window in front of it was moved or closed. This event handler receives a `Graphics</api/graphics/graphics>` object as a parameter that represents the graphics that will be drawn in the window. `Graphics</api/graphics/graphics>` objects have their own methods for drawing graphics.

<div id="desktopwindow.resized">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Resized

**Resized**

> The window has been resized by the user or by code that changes the window's Width or Height properties.

<div id="desktopwindow.resizing">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Resizing

**Resizing**

> The user is in the process of resizing the window.
>
> Resizing executes regardless of whether the LiveResize property is `True</api/language/true>`.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> The Top, Left, Width and Height properties have already been adjusted to account for sizing at this point if LiveResize is on, but the controls haven't drawn themselves. You could, for example, use a `Boolean</api/data_types/boolean>` property to indicate whether a `DesktopCanvas</api/user_interface/desktop/desktopcanvas>` control should redraw in its Paint event.
>
> </div>

<div id="desktopwindow.restored">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.Restored

**Restored**

> The window has been restored to its prior state from either being minimized or maximized.
>
> This event handler is called when the window is restored from a prior state.
>
> This can occur when the user selects one of the window buttons or menu commands for the action. The event handler may also be called using one of the following methods, depending on the state of the window:
>
> - `Maximize<desktopwindow.maximize>`
> - `Minimize<desktopwindow.minimize>`
> - `Restore<desktopwindow.restore>`

<div id="desktopwindow.scalefactorchanged">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopWindow.ScaleFactorChanged

**ScaleFactorChanged**

> The backing store scale factor has changed for this Window and the application should invalidate any cached bitmaps or other relevant state.

## Notes

Window constructors are called after the window and its controls are created, but before the Opening events are called. If you are initializing Window properties, you should do so using the `Opening<desktopwindow.opening>` event handler rather than the Constructor. Using the Constructor could result in property changes you make being overwritten by the built-in Window initializations.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Converting windows to containers

A window can be converted to a `DesktopContainer</api/user_interface/desktop/desktopcontainer>` by changing its Super Class to `DesktopContainer</api/user_interface/desktop/desktopcontainer>`. However, you cannot change the default window to a `DesktopContainer</api/user_interface/desktop/desktopcontainer>`.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Understanding sheet windows

A *Sheet Window* is the official name for a type of macOS window that is modal to a parent window. On other platforms, they behave as an ordinary movable modal dialog box.

A Sheet window can be displayed by passing a reference to the parent window when calling the `ShowModal<desktopwindow.showmodal>` method. If SheetWindow is defined as a Sheet window and MainWindow is a Document window, then the statement:

``` xojo
SheetWindow.ShowModal(Self)
```

will show the Sheet window using the calling window (in this case, MainWindow) as the Parent window.

You can also use your own instance like this:

``` xojo
Var sw As New SheetWindow
sw.ShowModal(Self)
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Custom cursors

The MouseCursor property controls the appearance of the pointer when it is over the window, provided the `MouseCursor</api/user_interface/desktop/desktopapplication>` property of the DesktopApplication class is `Nil</api/language/nil>`. If you also want the pointer to change to another shape when it is over a control within the window, you must either assign the new value to the Window's MouseCursor property or temporarily set the window's MouseCursor property to `Nil</api/language/nil>` and the control's `MouseCursor</api/user_interface/desktop/desktopuicontrol>` property to the desired cursor. See the section on the `MouseCursor</api/user_interface/desktop/mousecursor>` class for an example.

You can assign a MouseCursor using the library of cursors in the `Cursors</api/user_interface/desktop/cursors>` module.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### The resizing event handler

This example resizes three TextFields on the form in the `Resizing<desktopwindow.resizing>` event.The three TextFields are aligned horizontally. As the user stretches or shrinks the window, the TextFields' widths change proportionally.

``` xojo
Var availableSpace As Integer
Var field1Size, field2Size, field3Size As Integer

' subtract 40 pixels for the space between the
' three fields and on left and right side of the window
availableSpace = Me.Width - 40

' calculate the size of each field based on a percentage
field1Size = availableSpace * 0.6 ' 60 percent
field2Size = availableSpace * 0.3 ' 30 percent
field3Size = availableSpace * 0.1 ' 10 percent

' Set the field widths
TextField1.Width = field1Size
TextField2.Width = field2Size
TextField3.Width = field3Size

' reposition the fields based on the new sizes
TextField2.Left = TextField1.Left + TextField1.Width + 10
TextField3.Left = TextField2.Left + TextField2.Width + 10
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Contextual menu example

The following example shows how to present and handle a contextual menu in a window using the ConstructContextualMenu and ContextualMenuItemSelected event handlers.

The following code in a ConstructContextualMenu event builds a simple contextual menu. The parameter *base* (a `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>`) is passed in as a parameter and you add your contextual menu to it:

``` xojo
base.AddMenu(New DesktopMenuItem("Import"))
base.AddMenu(New DesktopMenuItem("Export"))
Return True  ' display the contextual menu
```

The following `Select</api/language/select_case>` statement in the ContextualMenuAction event handler inspects the selected menu item, which is passed in as the *selectedItem* (a `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>`) parameter.

``` xojo
Select Case selectedItem.Text
Case "Import"
  MessageBox("You chose Import")
Case "Export"
  MessageBox("You chose export")
End Select

Return True
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### DrawInto example

This example draws the contents of a window into a `Graphics</api/graphics/graphics>` object. For example, add a second window to a new project (Window2) and set its Visible property to `False</api/language/false>`. Add a variety of controls to Window2. In the Paint event of Window1, use this code to draw the second window into the first window:

``` xojo
Window2.DrawInto(g, 0, 0)
```

The contents of Window2 are drawn into Window1.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Accessing controls and properties in other windows

When changing a window property from another window, there are two possible approaches you can take. If you have only one instance of the window you need to reference, you can use the window's object name as a reference. For example, if you had a window called window1 that had a `DesktopTextField</api/user_interface/desktop/desktoptextfield>` called TextField1 and you wanted to assign the value "Fred" to the text property of that TextField, you would using the following syntax:

``` xojo
Window1.TextField1.Text = "Fred"
```

If you have multiple instances of the same window class open at the same time, then a reference to the target window must be included as in this example where a new window is opened and its window title changed. "anotherWindow" is a window class in the Project.

``` xojo
Var w As AnotherWindow
w = New AnotherWindow
w.Title = "Your Results"
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Handling drag and drop

For an explanation of handling drag and drop, see the `DesktopUIControl</api/user_interface/desktop/desktopuicontrol>` class and the `DragItem</api/user_interface/desktop/dragitem>` class.

## Sample code

This example sets the background color of the window to grey, provided the HasBackgroundColor property is set to `True</api/language/true>`.

``` xojo
BackgroundColor = Color.RGB(80, 80, 80)
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This example increases the width of the window by 20 pixels.

``` xojo
Width = Width + 20
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This example changes the title of the window.

``` xojo
Title = "Document 1"
```

## Compatibility

|                       |         |
|-----------------------|---------|
| **Project Types**     | Desktop |
| **Operating Systems** | All     |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `DesktopApplication.WindowAt<desktopapplication.windowat>` function; `MessageDialog</api/user_interface/desktop/messagedialog>` class.

</div>
