Table of Contents

Class Window

Namespace
Alternet.UI
Assembly
Alternet.UI.Common.dll

Represents a window that makes up an application's user interface.

[ControlCategory("Hidden")]
public class Window : Control, IBaseObjectWithId, IDisposableObject, IBaseObject, ISupportInitialize, IFocusable, ITextProperty, IComponent, INotifyDataErrorInfo, IWindow, IControl, IDisposable, IWin32Window
Inheritance
Window
Implements
Derived

Examples

Here is how to declare a Window in UIXML:

<Window xmlns="http://schemas.alternetsoft.com/ui/2021"
        xmlns:x="http://schemas.alternetsoft.com/ui/2021/uixml"
        x:Class="ApiDoc.WindowWindow"
        Title="Window" Name="window">
</Window>

Also, a Window can be created from code:

var wnd = new Alternet.UI.Window();

Remarks

A Window is a representation of any window displayed in your application. The point of interaction between a user and a standalone application is a window. A Window consists of two distinct areas:

  • A non-client area, which hosts the window adornments, including a title, minimize button, maximize button, close button, and a border.
  • A client area that hosts application-specific content.

Examples of how a Window can look on different platforms:

Set Title property to specify the title of this window.

Constructors

Window()

Initializes a new instance of the Window class.

Window(WindowKind)

Initializes a new instance of the Window class.

Properties

ActiveControl

Gets or sets active control.

ActiveWindow

Gets the currently active window for this application.

BorderStyle

Gets or sets border style of the window.

CloseAction

Gets or sets action which is performed when window is closed using Close() method.

CloseEnabled

Gets or sets a value indicating whether the window has an enabled close button.

ControlKind

Returns control identifier.

Default

Gets default window.

DefaultBounds

Gets or sets default location and position of the window.

DefaultDPI

Gets DPI of the first created window.

EnterModalResult

Gets or sets ModalResult of the ENTER key.

EscModalResult

Gets or sets ModalResult of the ESC key.

GlobalWindowNotifications

Gets global collection of the attached window notification objects. These notifications are called for the each created window.

Handler

Gets window handler.

HasBorder

Gets or sets a value indicating whether the window has a border.

HasSystemMenu

Gets or sets whether system menu is visible for this window.

HasTitleBar

Gets or sets a boolean value indicating whether window has title bar.

Icon

Gets or sets the icon for the window.

IncFontSize

Gets or sets default control font size increment (in points) on normal dpi displays (DPI less or equal to 96).

IncFontSizeHighDpi

Gets or sets default control font size increment (in points) on high dpi displays (DPI greater than 96).

IsActive

Gets a value indicating whether the window is the currently active window for this application.

IsMaximized

Gets or sets whether this window is maximized.

IsMinimized

Gets or sets whether this window is minimized.

IsOwnerVisible

Gets whether Owner is null or visible.

IsPopupWindow

Gets or sets a value indicating whether to create a special popup window.

IsToolWindow

A tool window does not appear in the Windows taskbar or in the window that appears when the user presses ALT+TAB. On Windows, a tool window doesn't have minimize and maximize buttons.

KeyPreview

Gets or sets a value indicating whether the form will receive key events before the event is passed to the control that has focus.

LastActivateTime

Gets time when window was last time activated.

LastShownAsDialogTime

Gets time when window was last time shown as modal dialog.

LogicalChildrenCollection

Returns a collection of elements which can be treated as "logical children" of this element.

MaximizeEnabled

Gets or sets a value indicating whether the window has an enabled maximize button.

Menu

Gets or sets the MainMenu that is displayed in the window.

MinimizeEnabled

Gets or sets a value indicating whether the window has an enabled minimize button.

Modal

Gets a value indicating whether this window is displayed modally.

ModalResult

Gets or sets the modal result value, which is the value that is used when dialog is shown in order to close it immediately.

OwnedWindows

Gets an array of Window objects that represent all windows that are owned by this window.

OwnedWindowsCollection

Gets a collection of Window objects that represent all windows that are owned by this window.

OwnedWindowsVisible

Gets or sets whether owned windows are visible.

Owner

Gets or sets the window that owns this window.

OwnersCollection

Gets collection of all owner windows (including those owning this window indirectly).

Parent

Gets or sets the parent container of the control.

ProcessIdle

Gets or sets whether Idle event is fired.

Resizable

Gets or sets a value indicating whether the window can be resized by user.

ShowInTaskbar

Gets or sets a value indicating whether the form is displayed in the Windows or Linux taskbar.

StartLocation

Gets or sets the position of the window when first shown.

State

Gets or sets a value that indicates whether window is minimized, maximized, or normal.

StatusBar

Gets or sets the StatusBar that is displayed in the window.

SupressEsc

Gets or sets whether to supress 'Esc' key.

TitleAsObject

Gets or sets the title of the control as object. There is also Title property.

TopMost

Gets or sets a value indicating whether the window should be placed above all non-topmost windows and should stay above them, even when the window is deactivated.

Visible

Gets or sets a value indicating whether the control and all its child controls are displayed.

VisibleOnScreen

Gets whether control is visible on screen.

Methods

Activate()

Activates the window.

AddGlobalWindowNotification(IControlNotification)

Adds IControlNotification object to the global list of window notifications.

ApplyStartLocation(AbstractControl?)

Applies StartLocation to the location of the window.

ApplyStartLocationOnce(AbstractControl?)

Applies StartLocation to the window position if StateFlags has no StartLocationApplied flag.

CanClose(bool)

Returns whether window can be closed. Optionally checks whether owned windows can be closed.

CenterOnParent(GenericOrientation)

Centers the window.

Close()

Closes the window.

Close(WindowCloseAction?)

Closes the window.

CloseIdle(WindowCloseAction?)

Closes the window when application goes to the idle state.

CreateAs<T>(WindowKind)

Creates window with specified type and window kind.

CreateHandler()

Creates a handler for the control.

DisposeManaged()

Override to dispose managed resources. Here we dispose all used object references.

EscapeOrEnterToDefaultButtonClick(KeyEventArgs)

Checks whether ESC or ENTER is pressed and raises default buttons click event if window is shown as a modal dialog.

GetDefaultBounds()

Gets default bounds assigned to the window.

GetWindowKind()

Gets window kind (window, dialog, control, miniframe).

GetWindowKindOverride()

Gets window kind used instead of the default value.

Lower()

Lowers the window to the bottom of the window hierarchy (Z-order). This function only works for top level windows.

OnActivated(EventArgs)

Called when the Activated event is raised.

OnAfterChildKeyDown(object?, KeyEventArgs)

Called after the KeyDown event of the child control is raised.

OnAlwaysOnTopChanged(EventArgs)

Called when the value of the TopMost property changes.

OnCloseEnabledChanged(EventArgs)

Called when the value of the CloseEnabled property changes.

OnClosed(EventArgs)

Raises the Closed event and calls OnClosed(EventArgs). See Closed event description for more details.

OnClosing(WindowClosingEventArgs)

Raises the Closing event and calls OnClosing(WindowClosingEventArgs). See Closing event description for more details.

OnDpiChanged(DpiChangedEventArgs)

Called when the DpiChanged event is raised.

OnHandlerLocationChanged(EventArgs)

Called when the native conrol location is changed.

OnHandlerSizeChanged(EventArgs)

Called when the native conrol size is changed.

OnHasBorderChanged(EventArgs)

Called when the value of the HasBorder property changes.

OnHasSystemMenuChanged(EventArgs)

Called when the value of the HasSystemMenu property changes.

OnHasTitleBarChanged(EventArgs)

Called when the value of the HasTitleBar property changes.

OnIconChanged(EventArgs)

Called when the value of the Icon property changes.

OnIdle(EventArgs)

Called when when the application finishes processing events and is about to enter the idle state.

OnIsToolWindowChanged(EventArgs)

Called when the value of the IsToolWindow property changes.

OnKeyDown(KeyEventArgs)

Called when the KeyDown event is raised.

OnMaximizeEnabledChanged(EventArgs)

Called when the value of the MaximizeEnabled property changes.

OnMenuChanged(EventArgs)

Called when the value of the Menu property changes.

OnMinimizeEnabledChanged(EventArgs)

Called when the value of the MinimizeEnabled property changes.

OnOwnerChanged(EventArgs)

Called when the value of the Owner property changes.

OnResizableChanged(EventArgs)

Called when the value of the Resizable property changes.

OnShowInTaskbarChanged(EventArgs)

Called when the value of the ShowInTaskbar property changes.

OnStateChanged(EventArgs)

Called when the value of the State property changes.

OnStatusBarChanged(EventArgs)

Called when the value of the StatusBar property changes.

OnSystemColorsChanged(EventArgs)

Called when the SystemColorsChanged event is raised.

OnToolBarChanged(EventArgs)

Called when the value of the ToolBar property changes.

ProcessShortcuts(KeyEventArgs)

Iterates through all child control's shortcuts and calls shortcut action if its key is pressed.

Raise()

Raises the window to the top of the window hierarchy (Z-order). This function only works for top level windows.

RaiseClosed(WindowClosedEventArgs?)

Raises Closed event and OnClosed(EventArgs) method.

RaiseClosing(WindowClosingEventArgs)

Raises Closing event and OnClosing(WindowClosingEventArgs) method.

RaiseDisplayChanged()

Raises DisplayChanged event if it is required.

RaiseNotifications(Action<IControlNotification>)

Calls the specified action for all the registered notifications.

RaiseStateChanged()

Raises StateChanged event and OnStateChanged(EventArgs) method.

RecreateAllHandlers()

Recreates all native controls in all windows.

RemoveGlobalWindowNotification(IControlNotification)

Removes IControlNotification object from the global list of window notifications.

SetLocationInRectI(HorizontalAlignment?, VerticalAlignment?, RectI, bool)

Aligns control location inside the specified rectangle using given horizontal and vertical alignment.

SetLocationInWindow(HorizontalAlignment?, VerticalAlignment?, AbstractControl?, bool)

Aligns control location inside the specified rectangle using given horizontal and vertical alignment.

SetLocationOnDisplay(PointI, Display?)

Sets relative location of this window on the specified display.

SetLocationOnDisplay(HorizontalAlignment?, VerticalAlignment?, Display?, bool)

Aligns window location inside the specified display's client area using given horizontal and vertical alignment.

ShowAndFocus(bool)

Shows window and focuses it.

ShowDialogAsync(Window?, Action<bool>?)

Runs a dialog asynchroniously.

UpdateDefaultFont()

Updates default control font after changes in IncFontSizeHighDpi or IncFontSize. You should not call this method directly.

Events

AlwaysOnTopChanged

Occurs when the value of the TopMost property changes.

CloseEnabledChanged

Occurs when the value of the CloseEnabled property changes.

Closed

Occurs when the window is closed.

Closing

Occurs before the window is closed.

DisplayChanged

Occurs when window moves to another display.

HasBorderChanged

Occurs when the value of the HasBorder property changes.

HasSystemMenuChanged

Occurs when the value of the HasSystemMenu property changes.

HasTitleBarChanged

Occurs when the value of the HasTitleBar property changes.

IconChanged

Occurs when the value of the Icon property changes.

IsToolWindowChanged

Occurs when the value of the IsToolWindow property changes.

Load

Occurs before a window is displayed for the first time.

MaximizeEnabledChanged

Occurs when the value of the MaximizeEnabled property changes.

MenuChanged

Occurs when the value of the Menu property changes.

MinimizeEnabledChanged

Occurs when the value of the MinimizeEnabled property changes.

OwnerChanged

Occurs when the value of the Owner property changes.

ResizableChanged

Occurs when the value of the Resizable property changes.

ShowInTaskbarChanged

Occurs when the value of the ShowInTaskbar property changes.

StateChanged

Occurs when the value of the State property changes.

StatusBarChanged

Occurs when the value of the StatusBar property changes.