Window

A top-level application window.

Constructors

this
this(string title, int width, int height)

Create and show-ready a top-level window with the given title and size (the size is the outer window size, in pixels).

Members

Functions

acceleratorTable
HACCEL acceleratorTable()

This window's accelerator table (the shortcuts of its attached menu), or null. The message loop translates accelerators against the *active* window's table, so each window keeps its own shortcuts.

close
void close()

Ask the window to close (drives the same path as the close button).

focusFirstControl
void focusFirstControl()

Move keyboard focus to the first focusable child control, if any.

processMessage
LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam)
Undocumented in source. Be warned that the author may not have intended to support it.
relayout
void relayout()

Re-run the root sizer over the current client area, if one is set.

setDefaultButton
void setDefaultButton(Control button)

Designate the button activated by Enter when focus is on a non-button control. A focused push button is always its own default regardless of this setting (native dialog behavior). Pass null to clear.

setIcon
void setIcon(HICON small, HICON large)

Set the window's icon, shown in the title bar, the taskbar and the Alt+Tab switcher. Pass the small and (optionally) large variants; if large is null the small icon is used for both. Load an icon with loadIcon (from the executable's resources) or loadIconFromFile.

setMenuBar
void setMenuBar(MenuBar menuBar)

Attach a menu bar to the window and install its keyboard accelerators. Re-lays out the contents, since the menu reduces the client area.

setMinimumSize
void setMinimumSize(int width, int height)

Set the smallest outer size the user may resize the window to, in pixels. Pass 0, 0 to remove the constraint. Without a minimum the layout engine clamps to zero but the user can still shrink the window until its contents collapse; a floor keeps a real app usable.

setSizer
void setSizer(Sizer sizer)

Install the root sizer and immediately lay it out over the client area.

setStatusBar
void setStatusBar(StatusBar statusBar)

Dock a status bar at the bottom of the window. Its height is reserved so the root sizer's content never overlaps it.

setTitle
void setTitle(string title)

Set the window title bar text.

show
void show()

Show the window and force an initial paint.

Variables

isMainWindow
bool isMainWindow;

Force this window to be treated as the application's main window: destroying it always quits the message loop (PostQuitMessage), even if other windows remain.

onClose
Event!(CloseEventArgs*) onClose;

Fired when the window is about to close; set args.cancel to veto.

onResize
Event!(int, int) onResize;

Fired on resize with the new client width and height.

Inherited Members

From Widget

handle_
HWND handle_;

The native window handle this widget owns (null until created).

parent_
Widget parent_;

The widget this one is parented to, if any.

children_
Widget[] children_;

Child widgets, in z/insertion order.

visible_
bool visible_;

Cached visibility flag.

bounds_
Rect bounds_;

Cached bounds (window-relative for children, screen-relative for windows).

handle
HWND handle()

The native window handle this widget owns (null until created).

parent
Widget parent()

The widget this one is parented to, if any. Read-only; see addChild.

children
Widget[] children()

The child widgets, in z/insertion order. Read-only; see addChild.

visible
bool visible()

Whether the widget is currently visible. Read-only; see setVisible.

bounds
Rect bounds()

The widget's last-known bounds. Read-only; see setBounds/getBounds.

rawHandle
HWND rawHandle()

Raw handle accessor for subclasses and the backend.

show
void show()

Make the widget visible.

hide
void hide()

Hide the widget.

setVisible
void setVisible(bool value)

Set visibility, updating the native window if it exists.

setBounds
void setBounds(Rect r)

Move/resize the widget, updating the native window if it exists.

getBounds
Rect getBounds()

The widget's last-known bounds.

getClientRect
Rect getClientRect()

The widget's client area (origin at 0,0). Empty if not yet created.

setEnabled
void setEnabled(bool enabled)

Enable or disable input for the widget.

isEnabled
bool isEnabled()

Whether the widget currently accepts input.

setFocus
void setFocus()

Give the widget keyboard focus.

invalidate
void invalidate()

Request a repaint of the whole widget.

getPreferredSize
Size getPreferredSize()

The widget's preferred size, used by the layout engine for non-stretching (proportion 0) items. The base widget has no intrinsic size; controls override this.

addChild
void addChild(Widget child)

Append a child and set its parent to this widget.

removeChild
void removeChild(Widget child)

Remove a child and clear its parent link. Unknown children are ignored.

dispose
void dispose()

Deterministically tear the widget down: dispose children, detach from the parent, destroy the native window, unregister it, and release the GC root. Idempotent — safe to call more than once.

registerHandle
void registerHandle()

Associate this widget's freshly-created HWND with the dispatch machinery and pin it as a GC root. Call once, immediately after handle is set.

processMessage
LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam)

Handle a window message routed from the master window procedure.

Meta