<div class="meta" robots="noindex">

</div>

Class

# Window

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

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2021r3. Please use `DesktopWindow</api/user_interface/desktop/desktopwindow>` as a replacement.

</div>

## Description

Any <span class="title-ref">Window</span>. A <span class="title-ref">Window</span> can be converted to a `DesktopContainer</api/user_interface/desktop/desktopcontainer>` by changing its Super Class to ContainerControl. However, you cannot change the default <span class="title-ref">Window</span> to a `DesktopContainer</api/user_interface/desktop/desktopcontainer>`.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                              | Type                                                   | Read-Only | Shared |
|---------------------------------------------------|--------------------------------------------------------|-----------|--------|
| `Backdrop<window.backdrop>`                       | `Picture</api/graphics/picture>`                       |           |        |
| `BackgroundColor<window.backgroundcolor>`         | `Color</api/data_types/color>`                         |           |        |
| `Bounds<window.bounds>`                           | `Rect</api/graphics/rect>`                             |           |        |
| `Changed<window.changed>`                         | `Boolean</api/data_types/boolean>`                     |           |        |
| `ControlCount<window.controlcount>`               | `Integer</api/data_types/integer>`                     | ✓         |        |
| `DefaultLocation<window.defaultlocation>`         | `Integer</api/data_types/integer>`                     |           |        |
| `DockItem<window.dockitem>`                       | `DockItem</api/macos/dockitem>`                        | ✓         |        |
| `Focus<window.focus>`                             | `RectControl</api/deprecated/rectcontrol>`             |           |        |
| `FullScreen<window.fullscreen>`                   | `Boolean</api/data_types/boolean>`                     |           |        |
| `Handle<window.handle>`                           | `Integer</api/data_types/integer>`                     | ✓         |        |
| `HasBackgroundColor<window.hasbackgroundcolor>`   | `Boolean</api/data_types/boolean>`                     |           |        |
| `HasCloseButton<window.hasclosebutton>`           | `Boolean</api/data_types/boolean>`                     | ✓         |        |
| `HasFullScreenButton<window.hasfullscreenbutton>` | `Boolean</api/data_types/boolean>`                     | ✓         |        |
| `HasMaximizeButton<window.hasmaximizebutton>`     | `Boolean</api/data_types/boolean>`                     | ✓         |        |
| `HasMinimizeButton<window.hasminimizebutton>`     | `Boolean</api/data_types/boolean>`                     | ✓         |        |
| `Height<window.height>`                           | `Integer</api/data_types/integer>`                     |           |        |
| `ImplicitInstance<window.implicitinstance>`       | `Boolean</api/data_types/boolean>`                     |           |        |
| `Left<window.left>`                               | `Integer</api/data_types/integer>`                     |           |        |
| `MaximumHeight<window.maximumheight>`             | `Integer</api/data_types/integer>`                     |           |        |
| `MaximumWidth<window.maximumwidth>`               | `Integer</api/data_types/integer>`                     |           |        |
| `MenuBar<window.menubar>`                         | `MenuBar</api/deprecated/menubar>`                     |           |        |
| `MinimumHeight<window.minimumheight>`             | `Integer</api/data_types/integer>`                     |           |        |
| `MinimumWidth<window.minimumwidth>`               | `Integer</api/data_types/integer>`                     |           |        |
| `MouseCursor<window.mousecursor>`                 | `MouseCursor</api/user_interface/desktop/mousecursor>` |           |        |
| `MouseX<window.mousex>`                           | `Integer</api/data_types/integer>`                     | ✓         |        |
| `MouseY<window.mousey>`                           | `Integer</api/data_types/integer>`                     | ✓         |        |
| `Resizeable<window.resizeable>`                   | `Boolean</api/data_types/boolean>`                     | ✓         |        |
| `ScaleFactor<window.scalefactor>`                 | `Double</api/data_types/double>`                       | ✓         |        |
| `SystemUIVisible<window.systemuivisible>`         | `Boolean</api/data_types/boolean>`                     |           |        |
| `Title<window.title>`                             | `String</api/data_types/string>`                       |           |        |
| `Top<window.top>`                                 | `Integer</api/data_types/integer>`                     |           |        |
| `TrueWindow<window.truewindow>`                   | Window                                                 | ✓         |        |
| `Type<window.type>`                               | `Integer</api/data_types/integer>`                     | ✓         |        |
| `Visible<window.visible>`                         | `Boolean</api/data_types/boolean>`                     |           |        |
| `Width<window.width>`                             | `Integer</api/data_types/integer>`                     |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                          | Parameters                                                                                                                                                                                                                             | Returns                            | Shared |
|-----------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|--------|
| `AcceptFileDrop<window.acceptfiledrop>`       | FileType As `String</api/data_types/string>`                                                                                                                                                                                           |                                    |        |
| `AcceptPictureDrop<window.acceptpicturedrop>` |                                                                                                                                                                                                                                        |                                    |        |
| `AcceptRawDataDrop<window.acceptrawdatadrop>` | Type As `String</api/data_types/string>`                                                                                                                                                                                               |                                    |        |
| `AcceptTextDrop<window.accepttextdrop>`       |                                                                                                                                                                                                                                        |                                    |        |
| `BitmapForCaching<window.bitmapforcaching>`   | width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`                                                                                                                                              | `Picture</api/graphics/picture>`   |        |
| `Close<window.close_method>`                  |                                                                                                                                                                                                                                        |                                    |        |
| `Control<window.control>`                     | index As `Integer</api/data_types/integer>`                                                                                                                                                                                            | `Control</api/deprecated/control>` |        |
| `Controls<window.controls>`                   |                                                                                                                                                                                                                                        | `Iterable</api/language/iterable>` |        |
| `DrawInto<window.drawinto>`                   | g As `Graphics</api/graphics/graphics>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                                                                                                              |                                    |        |
| `FocusNext<window.focusnext>`                 |                                                                                                                                                                                                                                        |                                    |        |
| `FocusPrevious<window.focusprevious>`         |                                                                                                                                                                                                                                        |                                    |        |
| `Hide<window.hide>`                           |                                                                                                                                                                                                                                        |                                    |        |
| `Invalidate<window.invalidate>`               | \[EraseBackground As `Boolean</api/data_types/boolean>`\]                                                                                                                                                                              |                                    |        |
| `Maximize<window.maximize_method>`            |                                                                                                                                                                                                                                        |                                    |        |
| `Minimize<window.minimize_method>`            |                                                                                                                                                                                                                                        |                                    |        |
| `Refresh<window.refresh>`                     | \[EraseBackground As `Boolean</api/data_types/boolean>`\]                                                                                                                                                                              |                                    |        |
| `RefreshRect<window.refreshrect>`             | 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>`, \[EraseBackground As `Boolean</api/data_types/boolean>`\] |                                    |        |
| `Restore<window.restore_method>`              |                                                                                                                                                                                                                                        |                                    |        |
| `SetFocus<window.setfocus>`                   |                                                                                                                                                                                                                                        |                                    |        |
| `Show<window.show>`                           |                                                                                                                                                                                                                                        |                                    |        |
| `ShowModal<window.showmodal>`                 |                                                                                                                                                                                                                                        |                                    |        |
| `ShowModalWithin<window.showmodalwithin>`     | parentWindow As Window                                                                                                                                                                                                                 |                                    |        |
| `ShowWithin<window.showwithin>`               | parentWindow As Window, \[facing As `Integer</api/data_types/integer>`\]                                                                                                                                                               |                                    |        |
| `UpdateNow<window.updatenow>`                 |                                                                                                                                                                                                                                        |                                    |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                      | Parameters                                                                                                                                                                              | Returns                            |
|-----------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| `Activate<window.activate>`                               |                                                                                                                                                                                         |                                    |
| `CancelClose<window.cancelclose>`                         | appQuitting As `Boolean</api/data_types/boolean>`                                                                                                                                       |                                    |
| `Close<window.close_event>`                               |                                                                                                                                                                                         |                                    |
| `ConstructContextualMenu<window.constructcontextualmenu>` | Base As `MenuItem</api/deprecated/menuitem>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                                                          | `Boolean</api/data_types/boolean>` |
| `ContentsChanged<window.contentschanged_event>`           |                                                                                                                                                                                         |                                    |
| `ContextualMenuAction<window.contextualmenuaction>`       | HitItem As `MenuItem</api/deprecated/menuitem>`                                                                                                                                         | `Boolean</api/data_types/boolean>` |
| `Deactivate<window.deactivate>`                           |                                                                                                                                                                                         |                                    |
| `DragEnter<window.dragenter>`                             | Obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`                                                                                   | `Boolean</api/data_types/boolean>` |
| `DragExit<window.dragexit>`                               | Obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`                                                                                   |                                    |
| `DragOver<window.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 `Integer</api/data_types/integer>` | `Boolean</api/data_types/boolean>` |
| `DropObject<window.dropobject>`                           | Obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`                                                                                   |                                    |
| `EnableMenuItems<window.enablemenuitems>`                 |                                                                                                                                                                                         |                                    |
| `KeyDown<window.keydown>`                                 | Key As `String</api/data_types/string>`                                                                                                                                                 | `Boolean</api/data_types/boolean>` |
| `KeyUp<window.keyup>`                                     | Key As `String</api/data_types/string>`                                                                                                                                                 |                                    |
| `Maximize<window.maximize_event>`                         |                                                                                                                                                                                         |                                    |
| `Minimize<window.minimize_event>`                         |                                                                                                                                                                                         |                                    |
| `MouseDown<window.mousedown>`                             | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                        | `Boolean</api/data_types/boolean>` |
| `MouseDrag<window.mousedrag>`                             | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                        |                                    |
| `MouseEnter<window.mouseenter>`                           |                                                                                                                                                                                         |                                    |
| `MouseExit<window.mouseexit>`                             |                                                                                                                                                                                         |                                    |
| `MouseMove<window.mousemove>`                             | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                        |                                    |
| `MouseUp<window.mouseup>`                                 | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                        |                                    |
| `MouseWheel<window.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<window.moved>`                                     |                                                                                                                                                                                         |                                    |
| `Open<window.open>`                                       |                                                                                                                                                                                         |                                    |
| `Paint<window.paint>`                                     | g As `Graphics</api/graphics/graphics>`, areas() As `Rect</api/graphics/rect>`                                                                                                          |                                    |
| `Resized<window.resized>`                                 |                                                                                                                                                                                         |                                    |
| `Resizing<window.resizing>`                               |                                                                                                                                                                                         |                                    |
| `Restore<window.restore_event>`                           |                                                                                                                                                                                         |                                    |
| `ScaleFactorChanged<window.scalefactorchanged>`           |                                                                                                                                                                                         |                                    |

## Constants

The following class constants of the `DragItem</api/user_interface/desktop/dragitem>` class can be used to specify the value of the Action parameter of the DragEnter, DragExit, and DragOver events.

| Class Constant    | Description            |
|-------------------|------------------------|
| DragActionDefault | Default action.        |
| DragActionCopy    | Copy the dragged item. |
| DragActionMove    | Move the dragged item. |
| DragActionLink    | Link the dragged item. |

## Enumerations

<div id="window.locations">

<div class="rst-class">

forsearch

</div>

</div>

Window.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="window.types">

<div class="rst-class">

forsearch

</div>

</div>

Window.Types

### Types

Specifies the type of window.

| Value          |
|----------------|
| Document       |
| MovableModal   |
| ModalDialog    |
| Floating       |
| PlainBox       |
| ShadowedBox    |
| Rounded        |
| GlobalFloating |
| Sheet          |
| ModelessDialog |

## Property descriptions

<div id="window.backdrop">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Backdrop

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

Gets or sets the picture object that will be drawn in the <span class="title-ref">Window</span>'s background.

You should not assign a new picture to the backdrop of the <span class="title-ref">Window</span> when being inside the paint event of that <span class="title-ref">Window</span>. 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 Open event.

``` xojo
Me.Backdrop = MyPicture
```

<div id="window.backgroundcolor">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.BackgroundColor

**BackgroundColor** As `Color</api/data_types/color>`

The background color for the object. The `HasBackgroundColor<window.hasbackgroundcolor>` property, must be set to `True</api/language/true>` to have the BackgroundColor displayed.

This code sets the `Window<window.hasbackgroundcolor>` property and sets the value of the BackgroundColor property:

``` xojo
Me.HasBackgroundColor = True
Me.BackgroundColor = &c110034
```

<div id="window.bounds">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Bounds

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

Use this property to Get/Set the true bounds of a <span class="title-ref">Window</span> (i.e. including frame/title decorations).

On Linux the Left/Top bounds exclude the decorations due to the way <span class="title-ref">Window</span> 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 Realbasic.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="window.changed">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Changed

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

Indicates whether the <span class="title-ref">Window</span> has been modified. The ContentsChanged event fires when the value of this property has changed. On macOS, the <span class="title-ref">Window</span>'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
  MsgBox("The contents have changed!")
Else
  MsgBox("The ContentsChanged event has not fired.")
End If
```

<div id="window.controlcount">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.ControlCount

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

The number of controls in the <span class="title-ref">Window</span>.

This property is read-only.

The following example is in the Action event of a `PushButton</api/deprecated/pushbutton>`. It displays the number of controls in the \`Window\`:

``` xojo
﻿﻿MsgBox(Self.ControlCount.ToString)
```

<div id="window.defaultlocation">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.DefaultLocation

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

If it's a Document <span class="title-ref">Window</span>, this property represents the <span class="title-ref">Window</span>'s location at which the <span class="title-ref">Window</span> will initially be placed when it opens.

The `Window<window.locations>` enumeration contains all potential values for this property.

<div id="window.dockitem">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.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 <span class="title-ref">Window</span> (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 <span class="title-ref">Window</span> 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 ClearRect property of the `Graphics</api/graphics/graphics>` class 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="window.focus">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Focus

**Focus** As `RectControl</api/deprecated/rectcontrol>`

Gets or sets the `RectControl</api/deprecated/rectcontrol>` in the <span class="title-ref">Window</span> 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="window.fullscreen">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.FullScreen

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

When set to `True</api/language/true>`, the <span class="title-ref">Window</span> resizes itself to cover the entire screen.

The values of the Left, Top, Width, and Height properties are adjusted to reflect the <span class="title-ref">Window</span>'s new position. They cannot be changed as long as FullScreen is `True</api/language/true>`. If MenuBarVisible is set to `True</api/language/true>`, the top of the <span class="title-ref">Window</span> will be partially covered by the menu bar in macOS. In the case of multiple monitors, the <span class="title-ref">Window</span> resizes to fit the monitor which contains the greatest portion of the <span class="title-ref">Window</span>.

FullScreen defaults to `False</api/language/false>`.

On macOS, you can instead set `Window<window.hasfullscreenbutton>` to True to let the user enable the macOS full screen mode.

<div id="window.handle">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Handle

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

Returns a handle to the <span class="title-ref">Window</span>. Use this instead of the deprecated MacWindowPtr and WinHWND.

This property is read-only.

When interfacing with Cocoa APIs using `Declares</api/language/declare>` <span class="title-ref">Window</span>.Handle always gives a NSWindow or NSPanel.

<div id="window.hasbackgroundcolor">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.HasBackgroundColor

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

If `True</api/language/true>`, the background color of the <span class="title-ref">Window</span> is set to the value of the `BackgroundColor<window.backgroundcolor>` property.

This property must be set in order for the value of the `BackgroundColor<window.backgroundcolor>` property to be applied to the <span class="title-ref">Window</span>.

This example sets the HasBackgroundColor property and sets the value of the BackgroundColor property.

``` xojo
Me.HasBackgroundColor = True
Me.BackgroundColor = &c110034
```

<div id="window.hasclosebutton">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.HasCloseButton

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

If `True</api/language/true>`, the <span class="title-ref">Window</span> will include a Close button in its Title Bar.

This property is read-only.

On macOS, if the `ContentsChanged</api/deprecated/window>` 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 <span class="title-ref">Window</span>.

MacOS does not display close buttons on Movable Modal windows.

<div id="window.hasfullscreenbutton">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.HasFullScreenButton

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

When set to `True</api/language/true>`, the <span class="title-ref">Window</span> 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, setting `FullScreen<window.fullscreen>` to True cause the <span class="title-ref">Window</span> to fill the screen although not using the native full screen mode so the behavior will be different.

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 to True. In order for the user to maximize a <span class="title-ref">Window</span> rather than put it into Full Screen Mode, they should Option-Click on the Maximize button or double-click the title bar.

<div id="window.hasmaximizebutton">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.HasMaximizeButton

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

If `True</api/language/true>`, the <span class="title-ref">Window</span> has an enabled Maximize button in its Title bar.

This property is read-only.

You can only change this setting while in the <span class="title-ref">Window</span> 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<window.hasfullscreenbutton>` to `True</api/language/true>`. In order for the user to maximize a <span class="title-ref">Window</span> rather than put it into Full Screen Mode, they should Option-Click on the Maximize button or double-click the title bar.

<div id="window.hasminimizebutton">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.HasMinimizeButton

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

If `True</api/language/true>`, the <span class="title-ref">Window</span> 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 <span class="title-ref">Window</span> Layout Editor.

<div id="window.height">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Height

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

The height of the content region of the <span class="title-ref">Window</span> in points.

``` xojo
Me.Height = 100
```

<div id="window.implicitinstance">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.ImplicitInstance

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

If `True</api/language/true>`, an instance of the <span class="title-ref">Window</span> can be instantiated implicitly. Set ImplicitInstance in the Properties Inspector in the IDE.

For example, an implicit instance is instantiated by referring to one of its properties or by calling its Show method. That is, a statement such as:

``` xojo
Window2.Show
```

or

``` xojo
Window2.ShowModal
```

will instantiate the <span class="title-ref">Window</span> only if ImplicitInstance is `True</api/language/true>`. The default is `True</api/language/true>`. If `False</api/language/false>`, you need to instantiate it explicitly via the `New</api/language/new>` operator. That is, only a statement such as:

``` xojo
w = New Window2
```

will instantiate the <span class="title-ref">Window</span>.

If ImplicitInstance is `False</api/language/false>`, statements such as:

``` xojo
Window2.Show
```

and references to any <span class="title-ref">Window</span> or control properties will produce an error.

<div id="window.left">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.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 <span class="title-ref">Window</span>.

The left frame of the <span class="title-ref">Window</span> is taken into account.

``` xojo
Me.Left = 50
```

<div id="window.maximumheight">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.MaximumHeight

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

The maximum height (in points) to which the <span class="title-ref">Window</span> can be resized.

<div id="window.maximumwidth">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.MaximumWidth

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

The maximum width (in points) to which the <span class="title-ref">Window</span> can be resized.

<div id="window.menubar">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.MenuBar

**MenuBar** As `MenuBar</api/deprecated/menubar>`

The menubar that is associated with the <span class="title-ref">Window</span>.

This is the `MenuBar</api/deprecated/menubar>` to use with the <span class="title-ref">Window</span>. Typically this is the MenuBar that was added to the project by default, but it can be any MenuBar in your project.

When the <span class="title-ref">Window</span> is active, this MenuBar is displayed.

On macOS, if no MenuBar is assigned to the <span class="title-ref">Window</span>, `Application<application.menubar>` is used. To hide the MenuBar, set the MenuBar property to None (in the Inspector) or Nil (in code) for both the <span class="title-ref">Window</span> and the Application.

On Microsoft Windows and Linux, a <span class="title-ref">Window</span> can have a MenuBar just below its title bar. The MenuBar assigned to the <span class="title-ref">Window</span> is used as the <span class="title-ref">Window</span> MenuBar. If the <span class="title-ref">Window</span> does not have a MenuBar specified (i.e. it is set to None in the Inspector or Nil in code), then the <span class="title-ref">Window</span> will not display a MenuBar.

<div class="note">

<div class="title">

Note

</div>

For MDI applications, the MDI <span class="title-ref">Window</span> uses `Application<application.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 <span class="title-ref">Window</span>.

</div>

This code in a PushButton 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="window.minimumheight">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.MinimumHeight

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

The minimum height to which the <span class="title-ref">Window</span> can be resized.

<div id="window.minimumwidth">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.MinimumWidth

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

The minimum width to which the <span class="title-ref">Window</span> can be resized.

<div id="window.mousecursor">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.MouseCursor

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

The cursor to be displayed while the mouse is within the <span class="title-ref">Window</span> 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/deprecated/control>` are ignored. If the <span class="title-ref">Window</span>'s MouseCursor property is not `Nil</api/language/nil>`, the MouseCursor properties of any `Controls</api/deprecated/control>` are ignored. You can use the cursors in the `Cursors</api/user_interface/desktop/cursors>` module to set the MouseCursor for the <span class="title-ref">Window</span>.

This line sets the default cursor to the finger pointer.

``` xojo
Me.MouseCursor = System.Cursors.FingerPointer
```

<div id="window.mousex">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.MouseX

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

The X coordinate of the mouse (points). Measured from the top-left corner of the <span class="title-ref">Window</span>.

This property is read-only.

<div id="window.mousey">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.MouseY

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

The Y coordinate of the mouse (points). Measured from the top-left corner of the <span class="title-ref">Window</span>.

This property is read-only.

<div id="window.resizeable">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Resizeable

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

If `True</api/language/true>`, the <span class="title-ref">Window</span> is resizeable. The default is `True</api/language/true>`.

This property is read-only.

You can only change this setting while in the <span class="title-ref">Window</span> Layout Editor.

<div id="window.scalefactor">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.ScaleFactor

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

The scale factor used when converting user space coordinates to backing store coordinates for this <span class="title-ref">Window</span>.

This property is read-only.

<div id="window.systemuivisible">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.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.

The behavior of this properties varies by OS. This is the behavior on current OS's (macOS Mojave, Windows 10, Linux Mint): \* Mac: When False (or OFF), the Dock and main menu bar are hidden when the <span class="title-ref">Window</span> is frontmost. \* Windows: When False (or OFF), the taskbar (including "Start" button) is hidden, regardless of whether your app is frontmost. \* Linux Mint: When False (or OFF), the <span class="title-ref">Window</span> menu bar is hidden (other distributions may have different behavior).

<div id="window.title">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Title

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

The text in the <span class="title-ref">Window</span>'s Title bar.

<div id="window.top">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.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 <span class="title-ref">Window</span>.

The Top value refers to the topmost part of the <span class="title-ref">Window</span> content region, which is the area starting below the <span class="title-ref">Window</span> Title Bar.

Setting Top = 0 moves the top of the windows content area to the top of the screen. On macOS, this puts the <span class="title-ref">Window</span> behind the main menu bar that appears at the top of the screen. To position a <span class="title-ref">Window</span> directly below the main menu bar, you should use `DesktopDisplay<desktopdisplay.availabletop>` to get the topmost position after the menu bar and then use `Window<window.bounds>` to position the <span class="title-ref">Window</span>.

<div id="window.truewindow">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.TrueWindow

**TrueWindow** As **Window**

Returns a reference to the actual enclosing <span class="title-ref">Window</span>.

This property is read-only.

TrueWindow walks up the <span class="title-ref">Window</span> hierarchy and finds the actual enclosing <span class="title-ref">Window</span> regardless of how deeply nested the `RectControl</api/deprecated/rectcontrol>` or `DesktopContainer</api/user_interface/desktop/desktopcontainer>` hierarchy is.

`RectControl</api/deprecated/rectcontrol>` also has a TrueWindow property.

<div id="window.type">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Type

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

The <span class="title-ref">Window</span> type. Set the desired Type in the Inspector.

This property is read-only.

Use the `Window<window.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 id="window.visible">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Visible

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

Controls the visibility of the <span class="title-ref">Window</span>.

If `True</api/language/true>`, the <span class="title-ref">Window</span> 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 <span class="title-ref">Window</span> not initially shown, setting Visible to `True</api/language/true>` is equivalent to calling the Show method.

<div id="window.width">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Width

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

The width of the content region of the <span class="title-ref">Window</span>.

The left and right <span class="title-ref">Window</span> frames are taken into account.

## Method descriptions

<div id="window.acceptfiledrop">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.AcceptFileDrop

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

Permits documents of type *FileType* to be dropped on the <span class="title-ref">Window</span>.

*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="window.acceptpicturedrop">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.AcceptPictureDrop

**AcceptPictureDrop**

Permits pictures to be dropped on the <span class="title-ref">Window</span>.

<div id="window.acceptrawdatadrop">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.AcceptRawDataDrop

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

Permits data (of the type specified) to be dropped on the <span class="title-ref">Window</span>. *Type* is a four-character resource code, e.g., 'snd ' or 'TEXT', or a UTI such as 'public.data' or 'public.jpeg'.

<div id="window.accepttextdrop">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.AcceptTextDrop

**AcceptTextDrop**

Permits text to be dropped on the <span class="title-ref">Window</span>.

<div id="window.bitmapforcaching">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.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 <span class="title-ref">Window</span>. 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 if width, height, or scale are less than or equal to zero
- 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
    pic.Graphics.ClearRect(0, 0, pic.Width, pic.Height)

    ' 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="window.close_method">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Close

**Close**

Closes the <span class="title-ref">Window</span>. Once closed, a <span class="title-ref">Window</span> cannot be refreshed or redrawn. Calling Close triggers the CancelClose event.

<div id="window.control">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Control

**Control**(index As `Integer</api/data_types/integer>`) As `Control</api/deprecated/control>`

The zero-based way to lookup controls in the <span class="title-ref">Window</span>.

All controls on the <span class="title-ref">Window</span> are returned as a the `Control</api/deprecated/control>` base type. You can use the IsA operator to check the specific type to see if the control is a PushButton, Label, etc.

This example is in the Action event of a `PushButton</api/deprecated/pushbutton>` and displays the name of the first control in \`Window\`:

``` xojo
MessageBox(Self.Control(0).Name)
```

Loop through all the controls on a <span class="title-ref">Window</span> and disable only the TextFields:

``` xojo
Var c As Control
For i As Integer = 0 To Self.ControlCount - 1
  c = Window.Control(i)
  If c IsA TextField Then
    TextField(c).Enabled = False
  End If
Next
```

<div id="window.controls">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Controls

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

Used to iterate through the controls on a <span class="title-ref">Window</span>.

All controls on the <span class="title-ref">Window</span> are returned as a the `Control</api/deprecated/control>` base type. You can use the IsA operator to check the specific type to see if the control is a PushButton, Label, etc.

Loop through all the controls on a <span class="title-ref">Window</span> and disable only the TextFields:

``` xojo
For Each c As Control In Self.Controls
  If c IsA TextField Then
    TextField(c).Enabled = False
  End If
Next
```

<div id="window.drawinto">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.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 <span class="title-ref">Window</span> into the specified `Graphics</api/graphics/graphics>` context.

<div id="window.focusnext">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.FocusNext

**FocusNext**

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

<div id="window.focusprevious">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.FocusPrevious

**FocusPrevious**

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

<div id="window.hide">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Hide

**Hide**

Makes the <span class="title-ref">Window</span> invisible.

<div id="window.invalidate">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Invalidate

**Invalidate**(\[EraseBackground As `Boolean</api/data_types/boolean>`\])

Similar to RefreshRect, but causes the specified region of the <span class="title-ref">Window</span> to be marked dirty and to be redrawn when the <span class="title-ref">Window</span> contents need to be redrawn. The region to be redrawn is specified by the *X*, *Y*, *Width*, and *Height* parameters.

The following example refreshes the <span class="title-ref">Window</span>. EraseBackground defaults to `True</api/language/true>`.

``` xojo
Self.Invalidate
```

<div id="window.maximize_method">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Maximize

**Maximize**

Maximizes the <span class="title-ref">Window</span> if it is not already maximized and calls the `Maximize event handler<window.maximize_event>`. If the <span class="title-ref">Window</span> was already maximized when you call this method, then it is restored to its prior state and calls the `Restore event handler<window.restore_event>`.

If the <span class="title-ref">Window</span> is not visible when Maximize is called, it becomes visible.

<div id="window.minimize_method">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Minimize

**Minimize**

Minimizes the <span class="title-ref">Window</span> and calls the `Minimize event handler<window.minimize_event>`.

<div id="window.refresh">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Refresh

**Refresh**(\[EraseBackground As `Boolean</api/data_types/boolean>`\])

Repaints the entire contents of the <span class="title-ref">Window</span>. If the optional parameter *EraseBackground* is `True</api/language/true>`, the background will be erased prior to redrawing the <span class="title-ref">Window</span>. The default is `True</api/language/true>`.

<div id="window.refreshrect">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.RefreshRect

**RefreshRect**(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>`, \[EraseBackground As `Boolean</api/data_types/boolean>`\])

Repaints only the region of the <span class="title-ref">Window</span> specified by the parameters *X*, *Y*, *Width*, and *Height*. *X* and *Y* are the coordinates of the top, left corner of the rectangle and *Width* and *Height* its width and height. All are in pixels. If the optional parameter *EraseBackground* is `True</api/language/true>`, the background will be erased prior to redrawing the area. The default is `True</api/language/true>`.

<div id="window.restore_method">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Restore

**Restore**

Restores a minimized or maximized <span class="title-ref">Window</span> to its previous size.

<div id="window.setfocus">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.SetFocus

**SetFocus**

Removes the focus from the control that currently has the focus, leaving no control with the focus.

On Windows, the app will continue to receive KeyDown events which it can accept by returning `True</api/language/true>` from the KeyDown event.

On macOS, this method does not do anything. Use the `ClearFocus</api/user_interface/desktop/clearfocus>` method to remove focus from the control on the <span class="title-ref">Window</span> that has the focus.

On Linux, this method works the same as `ClearFocus</api/user_interface/desktop/clearfocus>`.

Use the SetFocus method of the `RectControl</api/deprecated/rectcontrol>` class to set the focus to a particular control in the <span class="title-ref">Window</span>.

<div id="window.show">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Show

**Show**

Forces the <span class="title-ref">Window</span> to immediately become visible rather than wait until the application is idle. If `ImplicitInstance<window.implicitinstance>` is `False</api/language/false>`, then you need to instantiate an instance using `New</api/language/new>` before calling Show.

Calling Show immediately brings the <span class="title-ref">Window</span> to the front.

<div id="window.showmodal">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.ShowModal

**ShowModal**

Displays the <span class="title-ref">Window</span> and causes the current method to stop executing until the <span class="title-ref">Window</span> closes or becomes invisible.

If the <span class="title-ref">Window</span> is a Document <span class="title-ref">Window</span> it is shown as a normal Document <span class="title-ref">Window</span>. It becomes the frontmost <span class="title-ref">Window</span> but it is not modal. You must use a modal <span class="title-ref">Window</span> Frame type to force the <span class="title-ref">Window</span> into a modal state.

For Drawer or Sheet windows, you should use `ShowModalWithin<window.showmodalwithin>` to specify the parent <span class="title-ref">Window</span> to which the Drawer or Sheet is attached. Using just ShowModal without specifying the parent may result in Drawers and Sheets being attached to a <span class="title-ref">Window</span> you do not expect.

<div id="window.showmodalwithin">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.ShowModalWithin

**ShowModalWithin**(parentWindow As Window)

Displays the <span class="title-ref">Window</span> within the *parentWindow* in a modal state.

ShowModalWithin is designed to display Sheet windows within a specific parent (macOS only). If it is used to display a Document <span class="title-ref">Window</span>, it displays it as a non-modal dialog.

<div id="window.showwithin">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.ShowWithin

**ShowWithin**(parentWindow As Window, \[facing As `Integer</api/data_types/integer>`\])

Displays the <span class="title-ref">Window</span> within the *parentWindow*. If the <span class="title-ref">Window</span> is a Document <span class="title-ref">Window</span>, it is displayed in a modeless state and is equivalent to Show.

Used to display Sheet and Drawer windows on macOS within a specific parent. For sheet windows, it is displayed in a modal state. For a Drawer <span class="title-ref">Window</span> they are displayed in a modeless state. The optional *facing* parameter pertains to Drawer windows and indicates which side the drawer pops out of the side shown in the table below:

| Value                                               | Description                         |
|-----------------------------------------------------|-------------------------------------|
|                                                     |                                     |
| Default (determined by the system -- usually left), |                                     |
| 0                                                   | Top                                 |
| 1                                                   | Bottom                              |
| 2                                                   | Right                               |
| 3                                                   | Left (same ordering as tab panels). |

If you omit *facing*, the default value will be used.

<div id="window.updatenow">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.UpdateNow

**UpdateNow**

Flushes the back buffer on macOS windows. UpdateNow does not function unless ImplicitInstance is `True</api/language/true>`. If ImplicitInstance is `False</api/language/false>`, it will produce a compiler error.

Because macOS is double-buffered, drawing is accumulated before being shown on screen. You may want to flush the buffer manually after updating a progress bar, drawing the frame of an animation on a canvas, or other things of a similar nature. UpdateNow has no effect on Windows and Linux.

## Event descriptions

<div id="window.activate">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Activate

**Activate**

The <span class="title-ref">Window</span> is being activated.

In an app with multiple windows, the Activate event fires each time the <span class="title-ref">Window</span> becomes the frontmost. This includes when it opens. When the <span class="title-ref">Window</span> first opens, the Open event fires prior to the Activate event. Subsequent activations fire the Activate event but not the Open event.

<div id="window.cancelclose">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.CancelClose

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

The <span class="title-ref">Window</span> is about to be closed by the user clicking the close button, by calling the `Quit</api/language/quit>` or `Window</api/deprecated/window>` methods.

When the app is quitting, `CancelClose<window.cancelclose>` and `Close</api/deprecated/window>` are called as a pair for each open <span class="title-ref">Window</span>. `Close</api/deprecated/window>` will be called after `CancelClose<window.cancelclose>` executes, assuming that the close wasn't canceled by the user.

`Return</api/language/return>` `True</api/language/true>` to prevent the <span class="title-ref">Window</span> (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 <span class="title-ref">Window</span> is being closed because the whole app is quitting and `False</api/language/false>` when only the <span class="title-ref">Window</span> is being closed.

<div id="window.close_event">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Close

**Close**

The <span class="title-ref">Window</span> 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 <span class="title-ref">Window</span> should be closed, use `Window<window.cancelclose>` event instead which is called before `Window</api/deprecated/window>`.

<div id="window.constructcontextualmenu">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.ConstructContextualMenu

**ConstructContextualMenu**(Base As `MenuItem</api/deprecated/menuitem>`, 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 <span class="title-ref">Window</span>.

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 `RectControl</api/deprecated/rectcontrol>` 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.Add(New MenuItem("Test 1" )
base.Add(New MenuItem("Test 2"))
base.Add(New MenuItem("Test 3"))

' Add a Separator
base.Add(New MenuItem(MenuItem.TextSeparator))

' Add a sub menu
Var submenu As New MenuItem("SubMenu")
submenu.Add(New MenuItem("SubMenu Test 1"))
submenu.Add(New MenuItem("SubMenu Test 2"))
submenu.Add(New MenuItem("SubMenu Test 3"))
base.Add(submenu)

' Add a Separator
base.Add(New MenuItem(MenuItem.TextSeparator))

' Add an item that's on a menu bar so that you can see you don't
' have to handle every item returned.
base.Add(UntitledItem)

#If TargetMacOS Then
  ' because of how quitting the app is handled on Mac OS you cannot add the FileQuit item on OS X
#Else
  base.Add(FileQuit)
#EndIf

Return True
```

<div id="window.contentschanged_event">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.ContentsChanged

**ContentsChanged**

Fires when the value of the Changed property has changed. Changing the value of the Changed property triggers this event.

<div id="window.contextualmenuaction">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.ContextualMenuAction

**ContextualMenuAction**(HitItem As `MenuItem</api/deprecated/menuitem>`) As `Boolean</api/data_types/boolean>`

Fires when a contextual menuitem *HitItem* was selected but the `Action<menuitem.action>` event and the MenuHandler for the menuitem did not handle the menu selection.

This event gives you a chance to handle the menu selection by inspecting the menuitem's `Value<menuitem.value>` or `Tag<menuitem.tag>` properties to see which item was selected. Use this in conjunction with `ConstructContextualMenu<window.constructcontextualmenu>` if you have not specified the `Action<menuitem.action>` 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 `MenuItem</api/deprecated/menuitem>` is passed in as a parameter.

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

The following `Select Case</api/language/select_case>` statement in the ContextualMenuAction event handler inspects the selected menu item, which is passed in as the *HitItem* as `MenuItem</api/deprecated/menuitem>` parameter.

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

Return True
```

<div id="window.deactivate">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Deactivate

**Deactivate**

The <span class="title-ref">Window</span> is being deactivated. For example, a <span class="title-ref">Window</span> belonging to another app is being activated.

<div id="window.dragenter">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.DragEnter

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

Fired when the `DragItem</api/user_interface/desktop/dragitem>` enters the <span class="title-ref">Window</span>. Return `True</api/language/true>` from this event to prevent the drop from occurring.

The *Action* parameter specifies the drag action. It can take the following class constants of the `DragItem</api/user_interface/desktop/dragitem>` class:

| Class Constant    |
|-------------------|
| DragActionDefault |
| DragActionCopy    |
| DragActionMove    |
| DragActionLink    |

For example, the expression “DragItem.DragActionDefault” specifies the default drag action.

<div id="window.dragexit">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.DragExit

**DragExit**(Obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`)

Fires when the `DragItem</api/user_interface/desktop/dragitem>` exits the <span class="title-ref">Window</span>.

The *Action* parameter specifies the drag action. It can take the following class constants of the `DragItem</api/user_interface/desktop/dragitem>` class:

| Class Constant    |
|-------------------|
| DragActionDefault |
| DragActionCopy    |
| DragActionMove    |
| DragActionLink    |

<div id="window.dragover">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.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 `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

Fires when the `DragItem</api/user_interface/desktop/dragitem>` is over the <span class="title-ref">Window</span>.

The coordinates *x* and *y* are relative to the <span class="title-ref">Window</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 drag action. It can take the following class constants of the `DragItem</api/user_interface/desktop/dragitem>` class:

| Class Constant    |
|-------------------|
| DragActionDefault |
| DragActionCopy    |
| DragActionMove    |
| DragActionLink    |

<div id="window.dropobject">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.DropObject

**DropObject**(Obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`)

The item represented by *Obj* has been dropped on the <span class="title-ref">Window</span>.

The *Action* parameter specifies the drag action. It can take the following class constants of the `DragItem</api/user_interface/desktop/dragitem>` class:

| Class Constant    |
|-------------------|
| DragActionDefault |
| DragActionCopy    |
| DragActionMove    |
| DragActionLink    |

<div id="window.enablemenuitems">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.EnableMenuItems

**EnableMenuItems**

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="window.keydown">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.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 <span class="title-ref">Window</span>. For example, The tab key is never sent to any control. It is instead handled by the <span class="title-ref">Window</span> itself. If the <span class="title-ref">Window</span> has no controls that can receive the focus, any keys that are pressed will generate KeyDown events for the <span class="title-ref">Window</span>. 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 <span class="title-ref">Window</span> 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 <span class="title-ref">Window</span>. 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 <span class="title-ref">Window</span> 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="window.keyup">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.KeyUp

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

Fires when the passed *Key* is released and no other object on the <span class="title-ref">Window</span> has captured the event. It is not guaranteed to be the same key that received the `KeyDown<window.keydown>` event.

<div id="window.maximize_event">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Maximize

**Maximize**

The window has been 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<window.maximize_method>`
- `Minimize<window.minimize_method>`
- `Restore<window.restore_method>`

<div id="window.minimize_event">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Minimize

**Minimize**

The window has been minimized.

This event is called when the `Minimize<window.minimize_method>` 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 `Window</api/deprecated/window_method>` method and it is possible that it is the front-most (0 position) window.

<div id="window.mousedown">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.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 <span class="title-ref">Window</span> 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="window.mousedrag">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.MouseDrag

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

The mouse button was pressed inside the <span class="title-ref">Window</span> and moved (dragged) at the location local to the <span class="title-ref">Window</span> passed in to *x*, *y*. The user has moved the mouse inside the <span class="title-ref">Window</span> (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 <span class="title-ref">Window</span> coordinates. This event will not occur unless you return `True</api/language/true>` in the MouseDown event.

<div id="window.mouseenter">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.MouseEnter

**MouseEnter**

The user has moved the mouse inside the <span class="title-ref">Window</span> from a location outside the <span class="title-ref">Window</span>.

<div id="window.mouseexit">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.MouseExit

**MouseExit**

The user has moved the mouse outside the <span class="title-ref">Window</span> from a location inside the <span class="title-ref">Window</span>.

<div id="window.mousemove">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.MouseMove

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

The user has moved the mouse inside the <span class="title-ref">Window</span>.

This event handler receives parameters that indicate where the mouse is in local <span class="title-ref">Window</span> coordinates. The mouse has moved within the <span class="title-ref">Window</span> to the *x*, *y* local coordinates passed.

<div id="window.mouseup">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.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 <span class="title-ref">Window</span> coordinates.

<div id="window.mousewheel">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.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="window.moved">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Moved

**Moved**

The <span class="title-ref">Window</span> has been moved by the user or by code that changes the <span class="title-ref">Window</span>'s Left or Top properties.

<div id="window.open">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Open

**Open**

The <span class="title-ref">Window</span> is about to open but hasn't been displayed yet. Controls also receive Open events. A <span class="title-ref">Window</span> receives its Open event after all of the controls have received their Open events.

You should use the Open event instead of the Constructor for initialization.

After the <span class="title-ref">Window</span> opens and becomes the active <span class="title-ref">Window</span>, the Activate event is called.

<div id="window.paint">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Paint

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

Some portion of the <span class="title-ref">Window</span> needs to be redrawn either because the <span class="title-ref">Window</span> is opening or it has been exposed when a <span class="title-ref">Window</span> 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 <span class="title-ref">Window</span>. `Graphics</api/graphics/graphics>` objects have their own methods for drawing graphics.

<div id="window.resized">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Resized

**Resized**

The <span class="title-ref">Window</span> has been resized by the user or by code that changes the <span class="title-ref">Window</span>'s Width or Height properties.

<div id="window.resizing">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Resizing

**Resizing**

The user is in the process of resizing the <span class="title-ref">Window</span>.

Resizing executes regardless of whether the LiveResize property is `True</api/language/true>`. Note: 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 `Canvas</api/deprecated/canvas>` control should redraw in its Paint event.

<div id="window.restore_event">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.Restore

**Restore**

The window is being 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<window.maximize_method>`
- `Minimize<window.minimize_method>`
- `Restore<window.restore_method>`

<div id="window.scalefactorchanged">

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

</div>

<div class="rst-class">

forsearch

</div>

Window.ScaleFactorChanged

**ScaleFactorChanged**

The backing store scale factor has changed for this <span class="title-ref">Window</span> and the application should invalidate any cached bitmaps or other relevant state.

## Notes

Window constructors are called after the <span class="title-ref">Window</span> and its controls are created, but before the Open events are called. If you are initializing <span class="title-ref">Window</span> properties, you should do so using the `Open<window.open>` event handler rather than the Constructor. Using the Constructor could result in property changes you make being overwritten by the built-in <span class="title-ref">Window</span> initializations.

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

### Understanding sheet windows

A "Sheet <span class="title-ref">Window</span>" is the official name for drop-down dialog boxes that were introduced with macOS, where they often used in place of modal dialog boxes. Sheet windows behave as such only on OS X. On other platforms, they behave as ordinary movable modal dialog boxes.

A Sheet <span class="title-ref">Window</span> behaves like a Modal dialog <span class="title-ref">Window</span>, except that the animation makes it appear to drop down from the parent <span class="title-ref">Window</span>'s Title bar. It can't be moved from that position and it puts the user interface in a modal state. The user must respond to the choices presented in the Sheet <span class="title-ref">Window</span>.

A Sheet <span class="title-ref">Window</span> can be displayed by calling the `ShowModalWithin<window.showmodalwithin>` method. If SheetWindow is defined as a Sheet <span class="title-ref">Window</span> and MainWindow is a Document <span class="title-ref">Window</span>, then the statement:

``` xojo
SheetWindow.ShowModalWithin(Self)
```

will show the Sheet <span class="title-ref">Window</span> using the calling <span class="title-ref">Window</span> (in this case, MainWindow) as the Parent <span class="title-ref">Window</span>.

Note that the above works because SheetWindow has its ImplicitInstance property set to `True</api/language/true>`.

You can also use your own instance like this:

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

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

### Custom cursors

The MouseCursor property controls the appearance of the pointer when it is over the <span class="title-ref">Window</span>, provided the `MouseCursor</api/user_interface/desktop/desktopapplication>` property of the Application 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 <span class="title-ref">Window</span>, you must either assign the new value to the <span class="title-ref">Window</span>'s MouseCursor property or temporarily set the <span class="title-ref">Window</span>'s MouseCursor property to `Nil</api/language/nil>` and the control's `MouseCursor</api/deprecated/control>` 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.

## Sample code

This example sets the background color of the <span class="title-ref">Window</span> 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 <span class="title-ref">Window</span> by 20 pixels.

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

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

This example changes the title of the <span class="title-ref">Window</span>.

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

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

This example resizes three TextFields on the form in the `Resizing<window.resizing>` event.The three TextFields are aligned horizontally. As the user stretches or shrinks the <span class="title-ref">Window</span>, 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
```

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

The following example shows how to present and handle a contextual menu in a <span class="title-ref">Window</span> using the ConstructContextualMenu and ContextualMenuAction event handlers.

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

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

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

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

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

Return True
```

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

This example draws the contents of a <span class="title-ref">Window</span> into a `Graphics</api/graphics/graphics>` object. For example, add a second <span class="title-ref">Window</span> to a new project (Window2) and set its Visible property to False. Add a variety of controls to Window2. In the Paint event of Window1, use this code to draw the second <span class="title-ref">Window</span> into the first \`Window\`:

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

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

The contents of Window2 are drawn into Window1.

When changing a <span class="title-ref">Window</span> property from another <span class="title-ref">Window</span>, there are two possible approaches you can take. If you have only one instance of the <span class="title-ref">Window</span> you need to reference, you can use the <span class="title-ref">Window</span>'s object name as a reference. For example, if you had a <span class="title-ref">Window</span> called window1 that had a `TextField</api/deprecated/textfield>` 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 <span class="title-ref">Window</span> class open at the same time, then a reference to the target <span class="title-ref">Window</span> must be included as in this example where a new <span class="title-ref">Window</span> is opened and its <span class="title-ref">Window</span> title changed. "anotherWindow" is a <span class="title-ref">Window</span> class in the Project.

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

## Compatibility

All project types on all supported operating systems.

## See also

`Object</api/data_types/additional_types/object>` parent class; `Window<application.window>` function; `MessageDialog</api/user_interface/desktop/messagedialog>` class.
