HypernovaDesktop Components · docs
Binarymission
WinForms › Office Window › ModernChromeWindow

ModernChromeWindow

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WinForms.Controls.Windows

A Windows Forms window that draws its own title bar and border – in an Office, Visual Studio or Windows 8 style, or in your own colours – while keeping everything a standard window does: moving, resizing from every edge, the minimise, maximise and close buttons, and – with ShouldEnableWindowsKeyHooks – the Windows-key snapping shortcuts.

public partial class ModernChromeWindow : Form, IModernChromeHostWindow

Inherits from / implements: Form, IModernChromeHostWindow

Remarks

Using it

Derive your form from ModernChromeWindow instead of Form. Add controls to it as usual; the title bar and border sit outside the client area, so docking and anchoring work against the content area. Control.Text or TitlebarText is the caption, and Form.Icon is drawn at its left.

Themes

WindowChromeTheme picks one of the built-in looks; the default is WindowChromeTheme.OfficeBlack. Choosing a built-in theme sets the chrome colours, every command button's brushes and colours, and Control.BackColor, replacing any you had set. To use your own colours, set WindowChromeTheme to WindowChromeTheme.Custom first, then WindowChromeStartColor, WindowChromeEndColor, WindowChromeBorderColor and the command button properties. To draw the chrome entirely yourself, set ModernWindowChromeProvider.

Size of the frame

ChromeTitlebarHeight (32 by default) and ChromeBorderSize (8) are in logical pixels and scale with the display. Changing either grows or shrinks the window by the same amount, so the client area keeps its size, unless ShouldAutoResizeWindowHeightOnTitlebarHeightChange or ShouldAutoResizeWindowSizeOnBorderWidthChange is turned off.

The command buttons

Minimise, maximise/restore and close work by themselves. Handle WindowMinimizeRequested, WindowRestoreOrMaximizeRequested or WindowCloseRequested to take over a button: while the event has a handler the window no longer acts on that button itself – call Form.Close or set Form.WindowState in the handler. IsControlBoxEnabled greys all three out.

A window without a title bar

IsFullChromeDisabled keeps only the border – for a splash screen or a tool window that can still be moved and resized – and puts the title bar back as it was when turned off again.

Examples

A main window in the Visual Studio dark style, which asks before closing.

using System.Windows.Forms;
using Binarymission.WinForms.Controls.Windows;

public sealed class MainWindow : ModernChromeWindow
{
    public MainWindow()
    {
        Text = "Order Manager";
        WindowChromeTheme = WindowChromeTheme.VisualStudioDark;
        ChromeTitlebarHeight = 36;

        WindowCloseRequested += (sender, e) =>
        {
            if (MessageBox.Show(this, "Close Order Manager?", Text, MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                Close();
            }
        };

        Controls.Add(new DataGridView { Dock = DockStyle.Fill });
    }
}

See also

Members at a glance

Constructors
ModernChromeWindowCreates the window in the WindowChromeTheme.OfficeBlack theme, with a 32-pixel title bar, an 8-pixel border, centred on the screen.
Properties
AppIconLeftMarginGets or sets extra space before the window icon at the left of the title bar.
BackgroundBrushGets or sets the brush the content area is painted with while IsFormBackgroundPaintingInLinearGradientModeEnabled is on.
BackgroundDisabledCloseCommandButtonGets or sets the brush the close button is filled with while the buttons are disabled (IsControlBoxEnabled off).
BackgroundDisabledMaximizeRestoreCommandButtonGets or sets the brush the maximise/restore button is filled with while the buttons are disabled (IsControlBoxEnabled off).
BackgroundDisabledMinimizeCommandButtonGets or sets the brush the minimise button is filled with while the buttons are disabled (IsControlBoxEnabled off).
BackgroundHotCloseCommandButtonGets or sets the brush the close button is filled with while the pointer is over it.
BackgroundHotMaximizeRestoreCommandButtonGets or sets the brush the maximise/restore button is filled with while the pointer is over it.
BackgroundHotMinimizeCommandButtonGets or sets the brush the minimise button is filled with while the pointer is over it.
BackgroundNormalCloseCommandButtonGets or sets the brush the close button is filled with at rest.
BackgroundNormalMaximizeRestoreCommandButtonGets or sets the brush the maximise/restore button is filled with at rest.
BackgroundNormalMinimizeCommandButtonGets or sets the brush the minimise button is filled with at rest.
BackgroundPressedCloseCommandButtonGets or sets the brush the close button is filled with while it is held down.
BackgroundPressedMaximizeRestoreCommandButtonGets or sets the brush the maximise/restore button is filled with while it is held down.
BackgroundPressedMinimizeCommandButtonGets or sets the brush the minimise button is filled with while it is held down.
BorderColorDisabledCloseCommandButtonGets or sets the colour of the close button's outline while the buttons are disabled (IsControlBoxEnabled off).
BorderColorDisabledMaximiseRestoreCommandButtonGets or sets the colour of the maximise/restore button's outline while the buttons are disabled (IsControlBoxEnabled off).
BorderColorDisabledMinimizeCommandButtonGets or sets the colour of the minimise button's outline while the buttons are disabled (IsControlBoxEnabled off).
BorderColorHotCloseCommandButtonGets or sets the colour of the close button's outline while the pointer is over it.
BorderColorHotMaximiseRestoreCommandButtonGets or sets the colour of the maximise/restore button's outline while the pointer is over it.
BorderColorHotMinimizeCommandButtonGets or sets the colour of the minimise button's outline while the pointer is over it.
BorderColorNormalCloseCommandButtonGets or sets the colour of the close button's outline at rest.
BorderColorNormalMaximiseRestoreCommandButtonGets or sets the colour of the maximise/restore button's outline at rest.
BorderColorNormalMinimizeCommandButtonGets or sets the colour of the minimise button's outline at rest.
BorderColorPressedCloseCommandButtonGets or sets the colour of the close button's outline while it is held down.
BorderColorPressedMaximiseRestoreCommandButtonGets or sets the colour of the maximise/restore button's outline while it is held down.
BorderColorPressedMinimizeCommandButtonGets or sets the colour of the minimise button's outline while it is held down.
ChromeBorderSizeGets or sets the width of the border round the window, which is also the strip the user drags to resize it.
ChromeTitlebarHeightGets or sets the height of the title bar.
CloseCommandDisabledButtonImageGets or sets a picture drawn in place of the close button while the buttons are disabled (IsControlBoxEnabled off).
CloseCommandNormalButtonImageGets or sets a picture drawn in place of the close button at rest.
CloseCommandOnHoverButtonImageGets or sets a picture drawn in place of the close button while the pointer is over it.
CloseCommandOnPushedButtonImageGets or sets a picture drawn in place of the close button while it is held down.
ContainerChildGets or sets the panel that holds the window's content, for ShouldEnableContainerChildAutoManagement.
CreateParamsGets the parameters used to create this control's window, with the window styles this control needs added to them.
DefaultNormalWindowSizeGets or sets the size the window takes, centred on its screen, when it is restored from a snapped or docked position and has no earlier normal size to return to.
DisplayRectangleThe area inside the window available to its content, which is the client area less the custom chrome this window draws for itself.
EnableMinimizeRestoreActionUponTaskbarIconClickGets or sets whether clicking the window's taskbar button minimises it, and clicking again restores it, as with a standard window.
EnableMinimizeRestoreAnimationGets or sets whether Windows animates the window as it is minimised and restored.
ForegroundInternalVisualForDisabledCloseCommandButtonGets or sets the colour of the symbol on the close button while the buttons are disabled (IsControlBoxEnabled off).
ForegroundInternalVisualForDisabledMaximizeRestoreCommandButtonGets or sets the colour of the symbol on the maximise/restore button while the buttons are disabled (IsControlBoxEnabled off).
ForegroundInternalVisualForDisabledMinimizeCommandButtonGets or sets the colour of the symbol on the minimise button while the buttons are disabled (IsControlBoxEnabled off).
ForegroundInternalVisualForHotCloseCommandButtonGets or sets the colour of the symbol on the close button while the pointer is over it.
ForegroundInternalVisualForHotMaximizeRestoreCommandButtonGets or sets the colour of the symbol on the maximise/restore button while the pointer is over it.
ForegroundInternalVisualForHotMinimizeCommandButtonGets or sets the colour of the symbol on the minimise button while the pointer is over it.
ForegroundInternalVisualForNormalCloseCommandButtonGets or sets the colour of the symbol on the close button at rest.
ForegroundInternalVisualForNormalMaximizeRestoreCommandButtonGets or sets the colour of the symbol on the maximise/restore button at rest.
ForegroundInternalVisualForNormalMinimizeCommandButtonGets or sets the colour of the symbol on the minimise button at rest.
ForegroundInternalVisualForPressedCloseCommandButtonGets or sets the colour of the symbol on the close button while it is held down.
ForegroundInternalVisualForPressedMaximizeRestoreCommandButtonGets or sets the colour of the symbol on the maximise/restore button while it is held down.
ForegroundInternalVisualForPressedMinimizeCommandButtonGets or sets the colour of the symbol on the minimise button while it is held down.
FormBorderStyleGets the border style, which is always None: the window draws its own frame.
GapBetweenCommandButtonsGets or sets the space between the minimise, maximise and close buttons.
IsBeginResizeMessageRoutedFor the window's own message handling: whether the message that starts a resize has already been passed on, so one drag does not start two resizes.
IsBorderDrawnWhenWindowIsMaximisedGets or sets whether a maximised window keeps its border.
IsCloseBoxVisibleGets or sets whether the close button is shown.
IsControlBoxEnabledGets or sets whether the minimise, maximise/restore and close buttons respond; off, they are drawn disabled.
IsDoubleClickOnTitlebarActionResultingInWindowStateChangeEnabledGets or sets whether double-clicking the title bar maximises or restores the window.
IsFormBackgroundPaintingInLinearGradientModeEnabledGets or sets whether the content area is painted with BackgroundBrush instead of Control.BackColor.
IsFullChromeDisabledGets or sets whether the window is drawn with its border only: no title bar, icon, caption or command buttons, while it can still be moved and resized.
IsLocationAutoResettingAnchoredControlsEnabledNot used: setting it only repaints the window and its chrome.
IsTitlebarAndBorderBackgroundTransparentGets or sets whether the title bar background is see-through, like IsTitlebarBackgroundTransparent.
IsTitlebarBackgroundTransparentGets or sets whether the title bar background is see-through, so whatever is behind the window shows through it.
IsWindowControlBoxCommandsAutoCodeExecutionEnabledGets or sets whether the minimise, maximise/restore and close buttons act on the window by themselves when they have no event handler.
IsWindowLockedGets or sets whether the window is held where it is: the user cannot drag it by the title bar or move it from the system menu.
IsWindowResizingAllowedGets or sets whether the user can resize the window by dragging its border.
MaximizeCommandDisabledButtonImageGets or sets a picture drawn in place of the maximise button while the buttons are disabled (IsControlBoxEnabled off).
MaximizeCommandNormalButtonImageGets or sets a picture drawn in place of the maximise button at rest.
MaximizeCommandOnHoverButtonImageGets or sets a picture drawn in place of the maximise button while the pointer is over it.
MaximizeCommandOnPushedButtonImageGets or sets a picture drawn in place of the maximise button while it is held down.
MinimizeCommandDisabledButtonImageGets or sets a picture drawn in place of the minimise button while the buttons are disabled (IsControlBoxEnabled off).
MinimizeCommandNormalButtonImageGets or sets a picture drawn in place of the minimise button at rest.
MinimizeCommandOnHoverButtonImageGets or sets a picture drawn in place of the minimise button while the pointer is over it.
MinimizeCommandOnPushedButtonImageGets or sets a picture drawn in place of the minimise button while it is held down.
ModernWindowChromeProviderGets or sets an object that draws the title bar and border in place of the built-in drawing, and answers the mouse over them.
RestoreCommandDisabledButtonImageGets or sets a picture drawn in place of the restore button while the buttons are disabled (IsControlBoxEnabled off).
RestoreCommandNormalButtonImageGets or sets a picture drawn in place of the restore button at rest.
RestoreCommandOnHoverButtonImageGets or sets a picture drawn in place of the restore button while the pointer is over it.
RestoreCommandOnPushedButtonImageGets or sets a picture drawn in place of the restore button while it is held down.
ShouldAnchorTitlebarChildControlsToRightGets or sets whether the hosted title bar controls are kept against the right end of the title bar, just before the command buttons, as the window is resized.
ShouldAutoResizeWindowHeightOnTitlebarHeightChangeGets or sets whether the window grows or shrinks with ChromeTitlebarHeight, so the content area keeps its height.
ShouldAutoResizeWindowSizeOnBorderWidthChangeGets or sets whether the window grows or shrinks with ChromeBorderSize, so the content area keeps its size.
ShouldCycleWindowsHotKeyExecutionWhileWindowsKeyKeptPressedGets or sets whether pressing an arrow again while the Windows key is still held repeats its action – for example Win+Left, Left moves the window on from the left half – as Windows does.
ShouldDrawBorderForWindowChromeCommandButtonsGets or sets whether the minimise, maximise and close buttons are outlined, in the border colours for each state.
ShouldDrawResizeGripperNot used: no resize grip is drawn.
ShouldDrawWindowCommandButtonsOnTopRightEdgeIgnoringBorderSizeWhenInMaximizedModeNot used: the built-in drawing places the command buttons itself.
ShouldDrawWindowEdgesWithRoundedCornersGets or sets whether the window's corners are rounded.
ShouldEnableContainerChildAutoManagementGets or sets whether ContainerChild is made to fill the content area and size itself to its content.
ShouldEnableWindowsKeyHooksGets or sets whether the window answers the Windows-key snapping shortcuts itself – Win+Up to maximise, Win+Down to restore or minimise, Win+Left and Win+Right to snap to half the screen, Shift+Win+Left and Shift+Win+Right to move to the next screen – as a standard window does.
ShouldMaximizedWindowStateCoverTaskbarAreaGets or sets whether a maximised window covers the taskbar, as a full-screen application does.
ShouldRefreshChildrenWhenRepaintingNonClientAreaGets or sets whether the window's controls are repainted each time the title bar and border are.
ShouldRefreshClientAreaUponMaximizedWindowStateGets or sets whether the content area is repainted when the window is maximised.
ShouldRefreshNcAreaWhenInDesignModeGets or sets whether the title bar and border are repainted in the Visual Studio designer.
ShouldRefreshNonClientAreaWithDockedChildControlsGets or sets whether the designer repaints the title bar and border when docked child controls change the layout.
ShouldRenderAppIconGets or sets whether the window icon is drawn at the left of the title bar.
ShouldRenderAppIconUsingStandardSizeGets or sets whether the window icon is drawn at the standard 18 by 18 logical pixels, rather than sized to the title bar.
ShouldRenderAppTitlebarTextGets or sets whether the caption is drawn in the title bar.
ShouldRenderWindowCommandButtonsInsideChromeBorderWhenInNormalWindowStateNot used: the built-in drawing places the command buttons itself.
ShouldRepaintNonClientAreaWhenWindowIsBeingResizedGets or sets whether the title bar and border are repainted continuously while the user drags the window's size.
ShouldRunBaseCoreFor the window's own message handling: whether the standard window procedure runs for the message being handled.
TitleTextDrawingFormatGets or sets how the caption is laid out in the title bar.
TitlebarControlsGets (and helps set up) the child controls to be hosted on the title bar.
TitlebarControlsHostLocationGets or sets where the controls hosted in the title bar sit, in title bar coordinates.
TitlebarControlsHostLocationMaximumXOffsetGets the furthest right the hosted title bar controls can start, clear of the command buttons.
TitlebarControlsHostLocationMaximumYOffsetGets the lowest the hosted title bar controls can sit while staying inside the title bar.
TitlebarControlsHostMaximumWidthGets the widest the area for hosted title bar controls can be, leaving room for the command buttons.
TitlebarControlsHostSizeGets or sets the size of the area in the title bar that holds hosted controls.
TitlebarTextGets or sets the caption drawn in the title bar.
TopMarginForDrawingWindowChromeCommandButtonsGets or sets a top margin for the command buttons, kept no larger than the title bar allows.
WindowGets this window, for an IModernWindowChromeProvider that draws its chrome.
WindowChromeBorderColorGets or sets the colour of the border round the window.
WindowChromeCommandButtonSizeGets or sets the size of each of the minimise, maximise and close buttons.
WindowChromeEndColorGets or sets the second colour of the title bar's gradient.
WindowChromeGradientModeGets or sets the direction of the title bar's gradient from WindowChromeStartColor to WindowChromeEndColor.
WindowChromeStartColorGets or sets the first colour of the title bar's background, also used for the border while WindowChromeBorderColor is empty.
WindowChromeThemeGets or sets the built-in look of the title bar, border and command buttons.
WindowChromeTitleTextBrushGets or sets the brush the caption is drawn with.
WindowChromeTitleTextBrushWhenTitlebarBackgroundIsTransparentGets or sets the brush the caption is drawn with while IsTitlebarBackgroundTransparent is on.
WindowChromeTitleTextFontGets or sets the font of the caption.
WindowContextMenuGets or sets the shortcut menu shown when the user right-clicks the title bar.
WindowContextMenuCloseCommandImageGets or sets the picture beside the Close command on the title bar's shortcut menu.
WindowContextMenuCloseCommandTitleGets or sets the text of the Close command on the title bar's shortcut menu.
WindowContextMenuMaximizeCommandImageGets or sets the picture beside the Maximize command on the title bar's shortcut menu.
WindowContextMenuMaximizeCommandTitleGets or sets the text of the Maximize command on the title bar's shortcut menu.
WindowContextMenuMinimizeCommandImageGets or sets the picture beside the Minimize command on the title bar's shortcut menu.
WindowContextMenuMinimizeCommandTitleGets or sets the text of the Minimize command on the title bar's shortcut menu.
WindowContextMenuRestoreCommandImageGets or sets the picture beside the Restore command on the title bar's shortcut menu.
WindowContextMenuRestoreCommandTitleGets or sets the text of the Restore command on the title bar's shortcut menu.
WindowDockModeGets where the window is docked on its screen – snapped to the left or right half, maximised, minimised, or in its normal floating position.
WindowEdgeCornerRadiusGets or sets how far the window's corners are rounded, while ShouldDrawWindowEdgesWithRoundedCorners is on.
Methods
DisposeReleases the resources held by this ModernChromeWindow.
OnActivatedRaises the Activated event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
OnClientSizeChangedRaises the ClientSizeChanged event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
OnClosedRaises the Closed event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
OnClosingRaises the Closing event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
OnDeactivateRaises the Deactivate event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
OnDpiChangedRaises the DpiChanged event. ModernChromeWindow overrides it so the chrome is rebuilt for the new scale factor when the window is dragged to another display.
OnFormClosingRaises the FormClosing event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
OnHandleCreatedRaises the HandleCreated event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
OnKeyDownRaises the KeyDown event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
OnKeyUpRaises the KeyUp event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
OnLoadRaises the Load event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
OnMouseMoveRaises the MouseMove event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
OnMouseUpRaises the MouseUp event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
OnPaintRaises the Paint event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
OnPaintBackgroundRaises the PaintBackground event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
OnShownRaises the Shown event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
OnVisibleChangedRaises the VisibleChanged event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.
PerformExtendedNonClientRefresh// Gets or sets the color of the window chrome title bar border. //
PositionAndSizeWindowSets where the window appears and how big it is, applied when the window is first shown – or at once.
ProcessCmdKeyGives this control first sight of a command key, before the menu system and the parent form see it.
RefreshWindowNonClientRepaints the title bar and border.
SetBoundsCoreSets the bounds of this control, applying the constraints it imposes on its own size.
SetClientSizeCoreSets the client size, allowing for the custom chrome, so that asking for a client area of a given size actually yields one.
UpdateWindowTitleTextSets the caption and repaints the title bar at once.
WndProcProcesses the Windows messages sent to this control's window.
Events
WindowChromeBorderSizeChangedOccurs when ChromeBorderSize changes.
WindowChromeThemeChangedOccurs when WindowChromeTheme is set, after the theme's colours have been applied and before the chrome is repainted.
WindowChromeTitlebarHeightChangedOccurs when ChromeTitlebarHeight changes, after the window has been resized for it.
WindowCloseRequestedOccurs when the user clicks the close button.
WindowIconClickedOccurs when the user clicks the window icon at the left of the title bar.
WindowMinimizeRequestedOccurs when the user clicks the minimise button.
WindowRestoreOrMaximizeRequestedOccurs when the user clicks the maximise/restore button, or double-clicks the title bar.
WindowStateChangedOccurs when the window is minimised, maximised or restored, with the state before and after.

Constructors

ModernChromeWindow

public ModernChromeWindow()

Creates the window in the WindowChromeTheme.OfficeBlack theme, with a 32-pixel title bar, an 8-pixel border, centred on the screen.

Properties

AppIconLeftMargin

public int AppIconLeftMargin

Gets or sets extra space before the window icon at the left of the title bar.

Value
From 0 to 6 logical pixels; the default is 0. A value outside that range is drawn as 0.

BackgroundBrush

public BrushContainer BackgroundBrush

Gets or sets the brush the content area is painted with while IsFormBackgroundPaintingInLinearGradientModeEnabled is on.

Value
The default is null.
Remarks

Set its BrushContainer.Brush in code to a LinearGradientBrush for a gradient background.

BackgroundDisabledCloseCommandButton

public BrushContainer BackgroundDisabledCloseCommandButton

Gets or sets the brush the close button is filled with while the buttons are disabled (IsControlBoxEnabled off).

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

BackgroundDisabledMaximizeRestoreCommandButton

public BrushContainer BackgroundDisabledMaximizeRestoreCommandButton

Gets or sets the brush the maximise/restore button is filled with while the buttons are disabled (IsControlBoxEnabled off).

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

BackgroundDisabledMinimizeCommandButton

public BrushContainer BackgroundDisabledMinimizeCommandButton

Gets or sets the brush the minimise button is filled with while the buttons are disabled (IsControlBoxEnabled off).

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

BackgroundHotCloseCommandButton

public BrushContainer BackgroundHotCloseCommandButton

Gets or sets the brush the close button is filled with while the pointer is over it.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

BackgroundHotMaximizeRestoreCommandButton

public BrushContainer BackgroundHotMaximizeRestoreCommandButton

Gets or sets the brush the maximise/restore button is filled with while the pointer is over it.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

BackgroundHotMinimizeCommandButton

public BrushContainer BackgroundHotMinimizeCommandButton

Gets or sets the brush the minimise button is filled with while the pointer is over it.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

BackgroundNormalCloseCommandButton

public BrushContainer BackgroundNormalCloseCommandButton

Gets or sets the brush the close button is filled with at rest.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

BackgroundNormalMaximizeRestoreCommandButton

public BrushContainer BackgroundNormalMaximizeRestoreCommandButton

Gets or sets the brush the maximise/restore button is filled with at rest.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

BackgroundNormalMinimizeCommandButton

public BrushContainer BackgroundNormalMinimizeCommandButton

Gets or sets the brush the minimise button is filled with at rest.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

BackgroundPressedCloseCommandButton

public BrushContainer BackgroundPressedCloseCommandButton

Gets or sets the brush the close button is filled with while it is held down.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

BackgroundPressedMaximizeRestoreCommandButton

public BrushContainer BackgroundPressedMaximizeRestoreCommandButton

Gets or sets the brush the maximise/restore button is filled with while it is held down.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

BackgroundPressedMinimizeCommandButton

public BrushContainer BackgroundPressedMinimizeCommandButton

Gets or sets the brush the minimise button is filled with while it is held down.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

BorderColorDisabledCloseCommandButton

public Color BorderColorDisabledCloseCommandButton

Gets or sets the colour of the close button's outline while the buttons are disabled (IsControlBoxEnabled off).

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.
Remarks

BorderColorDisabledMaximiseRestoreCommandButton

public Color BorderColorDisabledMaximiseRestoreCommandButton

Gets or sets the colour of the maximise/restore button's outline while the buttons are disabled (IsControlBoxEnabled off).

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.
Remarks

BorderColorDisabledMinimizeCommandButton

public Color BorderColorDisabledMinimizeCommandButton

Gets or sets the colour of the minimise button's outline while the buttons are disabled (IsControlBoxEnabled off).

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.
Remarks

BorderColorHotCloseCommandButton

public Color BorderColorHotCloseCommandButton

Gets or sets the colour of the close button's outline while the pointer is over it.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.
Remarks

BorderColorHotMaximiseRestoreCommandButton

public Color BorderColorHotMaximiseRestoreCommandButton

Gets or sets the colour of the maximise/restore button's outline while the pointer is over it.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.
Remarks

BorderColorHotMinimizeCommandButton

public Color BorderColorHotMinimizeCommandButton

Gets or sets the colour of the minimise button's outline while the pointer is over it.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.
Remarks

BorderColorNormalCloseCommandButton

public Color BorderColorNormalCloseCommandButton

Gets or sets the colour of the close button's outline at rest.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.
Remarks

BorderColorNormalMaximiseRestoreCommandButton

public Color BorderColorNormalMaximiseRestoreCommandButton

Gets or sets the colour of the maximise/restore button's outline at rest.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.
Remarks

BorderColorNormalMinimizeCommandButton

public Color BorderColorNormalMinimizeCommandButton

Gets or sets the colour of the minimise button's outline at rest.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.
Remarks

BorderColorPressedCloseCommandButton

public Color BorderColorPressedCloseCommandButton

Gets or sets the colour of the close button's outline while it is held down.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.
Remarks

BorderColorPressedMaximiseRestoreCommandButton

public Color BorderColorPressedMaximiseRestoreCommandButton

Gets or sets the colour of the maximise/restore button's outline while it is held down.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.
Remarks

BorderColorPressedMinimizeCommandButton

public Color BorderColorPressedMinimizeCommandButton

Gets or sets the colour of the minimise button's outline while it is held down.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.
Remarks

ChromeBorderSize

public int ChromeBorderSize

Gets or sets the width of the border round the window, which is also the strip the user drags to resize it.

Value
In logical pixels. The default is 8.
Remarks

The window grows or shrinks to keep the content area's size unless ShouldAutoResizeWindowSizeOnBorderWidthChange is off. Raises WindowChromeBorderSizeChanged.

ChromeTitlebarHeight

public int ChromeTitlebarHeight

Gets or sets the height of the title bar.

Value
In logical pixels. The default is 32.
Remarks

The window grows or shrinks to keep the content area's height unless ShouldAutoResizeWindowHeightOnTitlebarHeightChange is off. Raises WindowChromeTitlebarHeightChanged.

CloseCommandDisabledButtonImage

public Bitmap CloseCommandDisabledButtonImage

Gets or sets a picture drawn in place of the close button while the buttons are disabled (IsControlBoxEnabled off).

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

CloseCommandNormalButtonImage

public Bitmap CloseCommandNormalButtonImage

Gets or sets a picture drawn in place of the close button at rest.

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

CloseCommandOnHoverButtonImage

public Bitmap CloseCommandOnHoverButtonImage

Gets or sets a picture drawn in place of the close button while the pointer is over it.

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

CloseCommandOnPushedButtonImage

public Bitmap CloseCommandOnPushedButtonImage

Gets or sets a picture drawn in place of the close button while it is held down.

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

ContainerChild

public Panel ContainerChild

Gets or sets the panel that holds the window's content, for ShouldEnableContainerChildAutoManagement.

Value
The default is null.
Remarks

The panel must already be one of the window's controls.

CreateParams

protected override CreateParams CreateParams

Gets the parameters used to create this control's window, with the window styles this control needs added to them.

DefaultNormalWindowSize

public Size DefaultNormalWindowSize

Gets or sets the size the window takes, centred on its screen, when it is restored from a snapped or docked position and has no earlier normal size to return to.

Value
The default is 1024 by 762 logical pixels.
Default
1024, 762

DisplayRectangle

public override Rectangle DisplayRectangle

The area inside the window available to its content, which is the client area less the custom chrome this window draws for itself.

EnableMinimizeRestoreActionUponTaskbarIconClick

public bool EnableMinimizeRestoreActionUponTaskbarIconClick

Gets or sets whether clicking the window's taskbar button minimises it, and clicking again restores it, as with a standard window.

Value
true to allow it; the default is true.
Remarks

Read when the window's handle is created: set it in the designer or the constructor, not later.

EnableMinimizeRestoreAnimation

public bool EnableMinimizeRestoreAnimation

Gets or sets whether Windows animates the window as it is minimised and restored.

Value
true to animate; the default is false.
Remarks

Read when the window's handle is created: set it in the designer or the constructor, not later.

ForegroundInternalVisualForDisabledCloseCommandButton

public Color ForegroundInternalVisualForDisabledCloseCommandButton

Gets or sets the colour of the symbol on the close button while the buttons are disabled (IsControlBoxEnabled off).

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

ForegroundInternalVisualForDisabledMaximizeRestoreCommandButton

public Color ForegroundInternalVisualForDisabledMaximizeRestoreCommandButton

Gets or sets the colour of the symbol on the maximise/restore button while the buttons are disabled (IsControlBoxEnabled off).

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

ForegroundInternalVisualForDisabledMinimizeCommandButton

public Color ForegroundInternalVisualForDisabledMinimizeCommandButton

Gets or sets the colour of the symbol on the minimise button while the buttons are disabled (IsControlBoxEnabled off).

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

ForegroundInternalVisualForHotCloseCommandButton

public Color ForegroundInternalVisualForHotCloseCommandButton

Gets or sets the colour of the symbol on the close button while the pointer is over it.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

ForegroundInternalVisualForHotMaximizeRestoreCommandButton

public Color ForegroundInternalVisualForHotMaximizeRestoreCommandButton

Gets or sets the colour of the symbol on the maximise/restore button while the pointer is over it.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

ForegroundInternalVisualForHotMinimizeCommandButton

public Color ForegroundInternalVisualForHotMinimizeCommandButton

Gets or sets the colour of the symbol on the minimise button while the pointer is over it.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

ForegroundInternalVisualForNormalCloseCommandButton

public Color ForegroundInternalVisualForNormalCloseCommandButton

Gets or sets the colour of the symbol on the close button at rest.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

ForegroundInternalVisualForNormalMaximizeRestoreCommandButton

public Color ForegroundInternalVisualForNormalMaximizeRestoreCommandButton

Gets or sets the colour of the symbol on the maximise/restore button at rest.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

ForegroundInternalVisualForNormalMinimizeCommandButton

public Color ForegroundInternalVisualForNormalMinimizeCommandButton

Gets or sets the colour of the symbol on the minimise button at rest.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

ForegroundInternalVisualForPressedCloseCommandButton

public Color ForegroundInternalVisualForPressedCloseCommandButton

Gets or sets the colour of the symbol on the close button while it is held down.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

ForegroundInternalVisualForPressedMaximizeRestoreCommandButton

public Color ForegroundInternalVisualForPressedMaximizeRestoreCommandButton

Gets or sets the colour of the symbol on the maximise/restore button while it is held down.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

ForegroundInternalVisualForPressedMinimizeCommandButton

public Color ForegroundInternalVisualForPressedMinimizeCommandButton

Gets or sets the colour of the symbol on the minimise button while it is held down.

Value
Set by each built-in WindowChromeTheme; set WindowChromeTheme to WindowChromeTheme.Custom before your own, or a theme chosen later replaces it.

FormBorderStyle

public new FormBorderStyle FormBorderStyle

Gets the border style, which is always None: the window draws its own frame.

Value
Always None; any other value is ignored. Use ChromeBorderSize and IsWindowResizingAllowed to change the frame.

GapBetweenCommandButtons

public int GapBetweenCommandButtons

Gets or sets the space between the minimise, maximise and close buttons.

Value
In logical pixels. The default is 0, the buttons touching.

IsBeginResizeMessageRouted

public bool IsBeginResizeMessageRouted

For the window's own message handling: whether the message that starts a resize has already been passed on, so one drag does not start two resizes.

Value
The default is false. Set and cleared by the window; applications should not change it.
Default
false

IsBorderDrawnWhenWindowIsMaximised

public bool IsBorderDrawnWhenWindowIsMaximised

Gets or sets whether a maximised window keeps its border.

Value
true to keep it; the default is true. Off, a maximised window's content reaches the screen edges.

IsCloseBoxVisible

public bool IsCloseBoxVisible

Gets or sets whether the close button is shown.

Value
true to show it; the default is true.
Remarks

The minimise and maximise buttons follow Form.MinimizeBox and Form.MaximizeBox on their own. To keep the buttons but stop them working, use IsControlBoxEnabled.

IsControlBoxEnabled

public bool IsControlBoxEnabled

Gets or sets whether the minimise, maximise/restore and close buttons respond; off, they are drawn disabled.

Value
true to enable them; the default is true.
Remarks

To hide the buttons rather than disable them, use Form.MinimizeBox, Form.MaximizeBox and IsCloseBoxVisible.

IsDoubleClickOnTitlebarActionResultingInWindowStateChangeEnabled

public bool IsDoubleClickOnTitlebarActionResultingInWindowStateChangeEnabled

Gets or sets whether double-clicking the title bar maximises or restores the window.

Value
true to allow it; the default is true.
Remarks

While it is on the double-click does what the maximise/restore button does: it raises WindowRestoreOrMaximizeRequested when that has a handler, and otherwise changes the state. Off, the double-click raises that event if it has a handler, and otherwise does nothing.

IsFormBackgroundPaintingInLinearGradientModeEnabled

public bool IsFormBackgroundPaintingInLinearGradientModeEnabled

Gets or sets whether the content area is painted with BackgroundBrush instead of Control.BackColor.

Value
true to use the brush; the default is false.
Remarks

Set BackgroundBrush as well: until it has a brush the plain background is drawn.

Example
BackgroundBrush = new BrushContainer
{
    Brush = new LinearGradientBrush(ClientRectangle, Color.White, Color.Gainsboro, LinearGradientMode.Vertical)
};
IsFormBackgroundPaintingInLinearGradientModeEnabled = true;

IsFullChromeDisabled

public bool IsFullChromeDisabled

Gets or sets whether the window is drawn with its border only: no title bar, icon, caption or command buttons, while it can still be moved and resized.

Value
true for a border-only window; the default is false.
Remarks

Turning it on hides the command buttons, icon and caption and collapses the title bar to 1 pixel; turning it off puts back the values they had just before. Use it for a splash screen, a tool palette or a pop-out panel.

IsLocationAutoResettingAnchoredControlsEnabled

public bool IsLocationAutoResettingAnchoredControlsEnabled

Not used: setting it only repaints the window and its chrome.

Value
The default is true. Kept for compatibility.

IsTitlebarAndBorderBackgroundTransparent

public bool IsTitlebarAndBorderBackgroundTransparent

Gets or sets whether the title bar background is see-through, like IsTitlebarBackgroundTransparent.

Value
true for a see-through title bar; the default is false.
Remarks

The built-in drawing makes only the title bar see-through, not the border. While this property or IsTitlebarBackgroundTransparent is on, Form.TransparencyKey is Color.Bisque: anything in the window drawn in exactly that colour shows through too. Turning both off clears it again.

IsTitlebarBackgroundTransparent

public bool IsTitlebarBackgroundTransparent

Gets or sets whether the title bar background is see-through, so whatever is behind the window shows through it.

Value
true for a see-through title bar; the default is false.
Remarks

The caption is then drawn with WindowChromeTitleTextBrushWhenTitlebarBackgroundIsTransparent. While this property or IsTitlebarAndBorderBackgroundTransparent is on, Form.TransparencyKey is Color.Bisque: anything in the window drawn in exactly that colour shows through too. Turning both off clears it again.

IsWindowControlBoxCommandsAutoCodeExecutionEnabled

public bool IsWindowControlBoxCommandsAutoCodeExecutionEnabled

Gets or sets whether the minimise, maximise/restore and close buttons act on the window by themselves when they have no event handler.

Value
true to let them act; the default is true.
Remarks

Off, a button with no WindowMinimizeRequested, WindowRestoreOrMaximizeRequested or WindowCloseRequested handler does nothing.

IsWindowLocked

public bool IsWindowLocked

Gets or sets whether the window is held where it is: the user cannot drag it by the title bar or move it from the system menu.

Value
true to lock it; the default is false.

IsWindowResizingAllowed

public bool IsWindowResizingAllowed

Gets or sets whether the user can resize the window by dragging its border.

Value
true to allow it; the default is true.

MaximizeCommandDisabledButtonImage

public Bitmap MaximizeCommandDisabledButtonImage

Gets or sets a picture drawn in place of the maximise button while the buttons are disabled (IsControlBoxEnabled off).

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

MaximizeCommandNormalButtonImage

public Bitmap MaximizeCommandNormalButtonImage

Gets or sets a picture drawn in place of the maximise button at rest.

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

MaximizeCommandOnHoverButtonImage

public Bitmap MaximizeCommandOnHoverButtonImage

Gets or sets a picture drawn in place of the maximise button while the pointer is over it.

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

MaximizeCommandOnPushedButtonImage

public Bitmap MaximizeCommandOnPushedButtonImage

Gets or sets a picture drawn in place of the maximise button while it is held down.

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

MinimizeCommandDisabledButtonImage

public Bitmap MinimizeCommandDisabledButtonImage

Gets or sets a picture drawn in place of the minimise button while the buttons are disabled (IsControlBoxEnabled off).

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

MinimizeCommandNormalButtonImage

public Bitmap MinimizeCommandNormalButtonImage

Gets or sets a picture drawn in place of the minimise button at rest.

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

MinimizeCommandOnHoverButtonImage

public Bitmap MinimizeCommandOnHoverButtonImage

Gets or sets a picture drawn in place of the minimise button while the pointer is over it.

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

MinimizeCommandOnPushedButtonImage

public Bitmap MinimizeCommandOnPushedButtonImage

Gets or sets a picture drawn in place of the minimise button while it is held down.

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

ModernWindowChromeProvider

public IModernWindowChromeProvider ModernWindowChromeProvider

Gets or sets an object that draws the title bar and border in place of the built-in drawing, and answers the mouse over them.

Value
The default is null: the window draws its own chrome.
Remarks

Implement IModernWindowChromeProvider for a look no theme gives. The provider is handed the window, through IModernChromeHostWindow, and a surface to draw on.

RestoreCommandDisabledButtonImage

public Bitmap RestoreCommandDisabledButtonImage

Gets or sets a picture drawn in place of the restore button while the buttons are disabled (IsControlBoxEnabled off).

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

RestoreCommandNormalButtonImage

public Bitmap RestoreCommandNormalButtonImage

Gets or sets a picture drawn in place of the restore button at rest.

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

RestoreCommandOnHoverButtonImage

public Bitmap RestoreCommandOnHoverButtonImage

Gets or sets a picture drawn in place of the restore button while the pointer is over it.

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

RestoreCommandOnPushedButtonImage

public Bitmap RestoreCommandOnPushedButtonImage

Gets or sets a picture drawn in place of the restore button while it is held down.

Value
The default is null: the button is drawn from its brush and colours.
Remarks

The picture is drawn at its own size in pixels, not scaled to the display, so supply one the size of WindowChromeCommandButtonSize.

ShouldAnchorTitlebarChildControlsToRight

public bool ShouldAnchorTitlebarChildControlsToRight

Gets or sets whether the hosted title bar controls are kept against the right end of the title bar, just before the command buttons, as the window is resized.

Value
true to keep them at the right; the default is false.

ShouldAutoResizeWindowHeightOnTitlebarHeightChange

public bool ShouldAutoResizeWindowHeightOnTitlebarHeightChange

Gets or sets whether the window grows or shrinks with ChromeTitlebarHeight, so the content area keeps its height.

Value
true to resize the window; the default is true.
Remarks

Off, the window keeps its size and the content area absorbs the change.

ShouldAutoResizeWindowSizeOnBorderWidthChange

public bool ShouldAutoResizeWindowSizeOnBorderWidthChange

Gets or sets whether the window grows or shrinks with ChromeBorderSize, so the content area keeps its size.

Value
true to resize the window; the default is true.
Remarks

Off, the window keeps its size and the content area absorbs the change.

ShouldCycleWindowsHotKeyExecutionWhileWindowsKeyKeptPressed

public bool ShouldCycleWindowsHotKeyExecutionWhileWindowsKeyKeptPressed

Gets or sets whether pressing an arrow again while the Windows key is still held repeats its action – for example Win+Left, Left moves the window on from the left half – as Windows does.

Value
true to repeat it; the window sets it to true when it is created.
Remarks

Used while ShouldEnableWindowsKeyHooks is on.

ShouldDrawBorderForWindowChromeCommandButtons

public bool ShouldDrawBorderForWindowChromeCommandButtons

Gets or sets whether the minimise, maximise and close buttons are outlined, in the border colours for each state.

Value
Set by each built-in theme; several of them turn it off.
See also

ShouldDrawResizeGripper

public bool ShouldDrawResizeGripper

Not used: no resize grip is drawn.

Value
The default is false. Kept for compatibility.

ShouldDrawWindowCommandButtonsOnTopRightEdgeIgnoringBorderSizeWhenInMaximizedMode

public bool ShouldDrawWindowCommandButtonsOnTopRightEdgeIgnoringBorderSizeWhenInMaximizedMode

Not used: the built-in drawing places the command buttons itself.

Value
The default is true. Kept for compatibility; setting it only repaints the chrome.

ShouldDrawWindowEdgesWithRoundedCorners

public bool ShouldDrawWindowEdgesWithRoundedCorners

Gets or sets whether the window's corners are rounded.

Value
true for rounded corners; the default is false.
Remarks

Each built-in WindowChromeTheme turns it off, so set it after the theme.

See also

ShouldEnableContainerChildAutoManagement

public bool ShouldEnableContainerChildAutoManagement

Gets or sets whether ContainerChild is made to fill the content area and size itself to its content.

Value
true to manage it; the default is false.
Remarks

Turning it on stores the panel's Control.AutoSize, Panel.AutoSizeMode and Control.Dock and sets them to true, grow-and-shrink and fill; turning it off puts them back. Ignored (the value does not change) while ContainerChild is not one of the window's controls.

ShouldEnableWindowsKeyHooks

public bool ShouldEnableWindowsKeyHooks

Gets or sets whether the window answers the Windows-key snapping shortcuts itself – Win+Up to maximise, Win+Down to restore or minimise, Win+Left and Win+Right to snap to half the screen, Shift+Win+Left and Shift+Win+Right to move to the next screen – as a standard window does.

Value
true to handle them; the default is false.
Remarks

A window that draws its own frame does not get these from Windows, so turn this on for a main application window. ShouldCycleWindowsHotKeyExecutionWhileWindowsKeyKeptPressed decides whether holding the Windows key and pressing an arrow again repeats the step.

ShouldMaximizedWindowStateCoverTaskbarArea

public bool ShouldMaximizedWindowStateCoverTaskbarArea

Gets or sets whether a maximised window covers the taskbar, as a full-screen application does.

Value
true to cover it; the default is false, which keeps a maximised window to the screen's working area.

ShouldRefreshChildrenWhenRepaintingNonClientArea

public bool ShouldRefreshChildrenWhenRepaintingNonClientArea

Gets or sets whether the window's controls are repainted each time the title bar and border are.

Value
true to repaint them; the default is true.
Remarks

Turn it off only if repainting the content is slow and it shows no artefacts without it.

ShouldRefreshClientAreaUponMaximizedWindowState

public bool ShouldRefreshClientAreaUponMaximizedWindowState

Gets or sets whether the content area is repainted when the window is maximised.

Value
The default is true.
Remarks

Turn it off only if a full repaint on maximising is too slow for your content.

ShouldRefreshNcAreaWhenInDesignMode

public bool ShouldRefreshNcAreaWhenInDesignMode

Gets or sets whether the title bar and border are repainted in the Visual Studio designer.

Value
The default is true. It affects only the designer.

ShouldRefreshNonClientAreaWithDockedChildControls

public bool ShouldRefreshNonClientAreaWithDockedChildControls

Gets or sets whether the designer repaints the title bar and border when docked child controls change the layout.

Value
The default is false. It affects only the Visual Studio designer.

ShouldRenderAppIcon

public bool ShouldRenderAppIcon

Gets or sets whether the window icon is drawn at the left of the title bar.

Value
true to draw it; the default is true.
See also

ShouldRenderAppIconUsingStandardSize

public bool ShouldRenderAppIconUsingStandardSize

Gets or sets whether the window icon is drawn at the standard 18 by 18 logical pixels, rather than sized to the title bar.

Value
true for the standard size; the default is true.

ShouldRenderAppTitlebarText

public bool ShouldRenderAppTitlebarText

Gets or sets whether the caption is drawn in the title bar.

Value
true to draw it; the default is true.

ShouldRenderWindowCommandButtonsInsideChromeBorderWhenInNormalWindowState

public bool ShouldRenderWindowCommandButtonsInsideChromeBorderWhenInNormalWindowState

Not used: the built-in drawing places the command buttons itself.

Value
The default is false. Kept for compatibility; setting it only repaints the chrome.

ShouldRepaintNonClientAreaWhenWindowIsBeingResized

public bool ShouldRepaintNonClientAreaWhenWindowIsBeingResized

Gets or sets whether the title bar and border are repainted continuously while the user drags the window's size.

Value
true to repaint during the drag; the default is false, which repaints when the drag ends.

ShouldRunBaseCore

public bool ShouldRunBaseCore

For the window's own message handling: whether the standard window procedure runs for the message being handled.

Value
Set and cleared by the window as it handles messages; applications should not change it.

TitleTextDrawingFormat

public StringFormat TitleTextDrawingFormat

Gets or sets how the caption is laid out in the title bar.

Value
By default centred across the title bar, on one line, trimmed with an ellipsis.
Remarks

Set StringFormat.Alignment to Near for a caption beside the icon, as in Windows 10 and 11.

TitlebarControls

public Control.ControlCollection TitlebarControls

Gets (and helps set up) the child controls to be hosted on the title bar.

TitlebarControlsHostLocation

public Point TitlebarControlsHostLocation

Gets or sets where the controls hosted in the title bar sit, in title bar coordinates.

Value
Ignored until the window has created its title bar host.
See also

TitlebarControlsHostLocationMaximumXOffset

public int TitlebarControlsHostLocationMaximumXOffset

Gets the furthest right the hosted title bar controls can start, clear of the command buttons.

Value
In pixels; it changes with the window's width.

TitlebarControlsHostLocationMaximumYOffset

public int TitlebarControlsHostLocationMaximumYOffset

Gets the lowest the hosted title bar controls can sit while staying inside the title bar.

Value
In pixels; it changes with ChromeTitlebarHeight.

TitlebarControlsHostMaximumWidth

public int TitlebarControlsHostMaximumWidth

Gets the widest the area for hosted title bar controls can be, leaving room for the command buttons.

Value
In pixels; it changes with the window's width.

TitlebarControlsHostSize

public Size TitlebarControlsHostSize

Gets or sets the size of the area in the title bar that holds hosted controls.

Value
Kept within the title bar: no wider than TitlebarControlsHostMaximumWidth and no taller than the title bar less the border. A width or height of 0 takes the largest allowed.

TitlebarText

public new string TitlebarText

Gets or sets the caption drawn in the title bar.

Value
The window's text.
See also

TopMarginForDrawingWindowChromeCommandButtons

public int TopMarginForDrawingWindowChromeCommandButtons

Gets or sets a top margin for the command buttons, kept no larger than the title bar allows.

Value
Set by each built-in WindowChromeTheme; WindowChromeTheme.Custom sets 3.
Remarks

The built-in drawing places the buttons itself and does not read this value, so changing it only repaints the chrome.

Window

public ModernChromeWindow Window

Gets this window, for an IModernWindowChromeProvider that draws its chrome.

WindowChromeBorderColor

public Color WindowChromeBorderColor

Gets or sets the colour of the border round the window.

Value
Set by each built-in WindowChromeTheme. Color.Empty draws the border in WindowChromeStartColor.

WindowChromeCommandButtonSize

public Size WindowChromeCommandButtonSize

Gets or sets the size of each of the minimise, maximise and close buttons.

Value
In device pixels, unlike the other metrics. The default is the system caption button size (CaptionButtonSize).

WindowChromeEndColor

public Color WindowChromeEndColor

Gets or sets the second colour of the title bar's gradient.

Value
Set by each built-in WindowChromeTheme; the plain themes use the same colour as WindowChromeStartColor.

WindowChromeGradientMode

public LinearGradientMode WindowChromeGradientMode

Gets or sets the direction of the title bar's gradient from WindowChromeStartColor to WindowChromeEndColor.

Value
The default is Vertical.

WindowChromeStartColor

public Color WindowChromeStartColor

Gets or sets the first colour of the title bar's background, also used for the border while WindowChromeBorderColor is empty.

Value
Set by each built-in WindowChromeTheme.
Remarks

With WindowChromeEndColor and WindowChromeGradientMode it makes the title bar's gradient. Set WindowChromeTheme to WindowChromeTheme.Custom first, or a theme chosen later replaces it.

WindowChromeTheme

public WindowChromeTheme WindowChromeTheme

Gets or sets the built-in look of the title bar, border and command buttons.

Value
The default is WindowChromeTheme.OfficeBlack.
Remarks

A built-in theme sets the chrome colours, the command buttons' brushes, colours and outlines, and Control.BackColor, replacing values you had set. WindowChromeTheme.Custom changes none of them, so set it before your own colours. Raises WindowChromeThemeChanged.

WindowChromeTitleTextBrush

public BrushContainer WindowChromeTitleTextBrush

Gets or sets the brush the caption is drawn with.

Value
White by default; the built-in themes may change it.
Remarks

Set its BrushContainer.Color for a plain colour, or its BrushContainer.Brush in code for a gradient.

WindowChromeTitleTextBrushWhenTitlebarBackgroundIsTransparent

public BrushContainer WindowChromeTitleTextBrushWhenTitlebarBackgroundIsTransparent

Gets or sets the brush the caption is drawn with while IsTitlebarBackgroundTransparent is on.

Value
The default is a BrushContainer in Color.SlateGray.
See also

WindowChromeTitleTextFont

public Font WindowChromeTitleTextFont

Gets or sets the font of the caption.

Value
The default is the window's font family at 10 points, bold.

WindowContextMenu

public ContextMenuStrip WindowContextMenu

Gets or sets the shortcut menu shown when the user right-clicks the title bar.

Value
By default a menu of Restore, Minimize, Maximize and Close.
Remarks

Assign your own menu to replace it.

WindowContextMenuCloseCommandImage

public Image WindowContextMenuCloseCommandImage

Gets or sets the picture beside the Close command on the title bar's shortcut menu.

Value
The default is the built-in close picture.
Remarks

Read when the window is created; set it in the constructor of a derived window.

WindowContextMenuCloseCommandTitle

public string WindowContextMenuCloseCommandTitle

Gets or sets the text of the Close command on the title bar's shortcut menu.

Value
The default is "Close application".
Remarks

Read when the window is created; set it in the constructor of a derived window, for example to translate it.

WindowContextMenuMaximizeCommandImage

public Image WindowContextMenuMaximizeCommandImage

Gets or sets the picture beside the Maximize command on the title bar's shortcut menu.

Value
The default is the built-in maximize picture.
Remarks

Read when the window is created; set it in the constructor of a derived window.

WindowContextMenuMaximizeCommandTitle

public string WindowContextMenuMaximizeCommandTitle

Gets or sets the text of the Maximize command on the title bar's shortcut menu.

Value
The default is "Maximize".
Remarks

Read when the window is created; set it in the constructor of a derived window, for example to translate it.

WindowContextMenuMinimizeCommandImage

public Image WindowContextMenuMinimizeCommandImage

Gets or sets the picture beside the Minimize command on the title bar's shortcut menu.

Value
The default is the built-in minimize picture.
Remarks

Read when the window is created; set it in the constructor of a derived window.

WindowContextMenuMinimizeCommandTitle

public string WindowContextMenuMinimizeCommandTitle

Gets or sets the text of the Minimize command on the title bar's shortcut menu.

Value
The default is "Minimize".
Remarks

Read when the window is created; set it in the constructor of a derived window, for example to translate it.

WindowContextMenuRestoreCommandImage

public Image WindowContextMenuRestoreCommandImage

Gets or sets the picture beside the Restore command on the title bar's shortcut menu.

Value
The default is the built-in restore picture.
Remarks

Read when the window is created; set it in the constructor of a derived window.

WindowContextMenuRestoreCommandTitle

public string WindowContextMenuRestoreCommandTitle

Gets or sets the text of the Restore command on the title bar's shortcut menu.

Value
The default is "Restore".
Remarks

Read when the window is created; set it in the constructor of a derived window, for example to translate it.

WindowDockMode

public DesktopDockMode WindowDockMode

Gets where the window is docked on its screen – snapped to the left or right half, maximised, minimised, or in its normal floating position.

Value
Updated when the window is shown and as the user snaps or restores it.
Remarks

WindowEdgeCornerRadius

public WindowEdgeCornerRadius WindowEdgeCornerRadius

Gets or sets how far the window's corners are rounded, while ShouldDrawWindowEdgesWithRoundedCorners is on.

Value
The default is 15 by 15.

Methods

Dispose

protected override void Dispose(bool disposing)

Releases the resources held by this ModernChromeWindow.

Parameters
disposing
true when called from Dispose; false when called from the finalizer.

OnActivated

protected override void OnActivated(EventArgs e)

Raises the Activated event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

OnClientSizeChanged

protected override void OnClientSizeChanged(EventArgs e)

Raises the ClientSizeChanged event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

OnClosed

protected override void OnClosed(EventArgs e)

Raises the Closed event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

OnClosing

protected override void OnClosing(CancelEventArgs e)

Raises the Closing event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

OnDeactivate

protected override void OnDeactivate(EventArgs e)

Raises the Deactivate event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

OnDpiChanged

protected override void OnDpiChanged(DpiChangedEventArgs e)

Raises the DpiChanged event. ModernChromeWindow overrides it so the chrome is rebuilt for the new scale factor when the window is dragged to another display.

Parameters
e
The event data.
Remarks

The built-in command button glyphs are cached as bitmaps sized for the display they were drawn on, so they are dropped here and rebuilt on the next non-client paint.

OnFormClosing

protected override void OnFormClosing(FormClosingEventArgs e)

Raises the FormClosing event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

OnHandleCreated

protected override void OnHandleCreated(EventArgs e)

Raises the HandleCreated event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

OnKeyDown

protected override void OnKeyDown(KeyEventArgs e)

Raises the KeyDown event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

OnKeyUp

protected override void OnKeyUp(KeyEventArgs e)

Raises the KeyUp event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

OnLoad

protected override void OnLoad(EventArgs e)

Raises the Load event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

OnMouseMove

protected override void OnMouseMove(MouseEventArgs e)

Raises the MouseMove event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

OnMouseUp

protected override void OnMouseUp(MouseEventArgs e)

Raises the MouseUp event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

OnPaint

protected override void OnPaint(PaintEventArgs e)

Raises the Paint event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

OnPaintBackground

protected override void OnPaintBackground(PaintEventArgs e)

Raises the PaintBackground event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

OnShown

protected override void OnShown(EventArgs e)

Raises the Shown event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

OnVisibleChanged

protected override void OnVisibleChanged(EventArgs e)

Raises the VisibleChanged event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior.

Parameters
e
The data for the event.

PerformExtendedNonClientRefresh

public void PerformExtendedNonClientRefresh()

// Gets or sets the color of the window chrome title bar border. //

See also

PositionAndSizeWindow

public void PositionAndSizeWindow(int left, int top, int width, int height, bool performActionNow

Sets where the window appears and how big it is, applied when the window is first shown – or at once.

Parameters
left
The window's left edge, in screen pixels.
top
The window's top edge, in screen pixels.
width
The window's width, in pixels, including the chrome.
height
The window's height, in pixels, including the chrome.
performActionNow
true to move the window now as well; the window's handle must then already exist. The default, false, only records the bounds for when the window is shown.
Remarks

Use it to restore a window to the bounds saved when it last closed: the bounds are applied after the window has finished its own layout, so nothing moves it afterwards.

ProcessCmdKey

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)

Gives this control first sight of a command key, before the menu system and the parent form see it.

RefreshWindowNonClient

public void RefreshWindowNonClient(bool shouldPerformExtendedRefresh

Repaints the title bar and border.

Parameters
shouldPerformExtendedRefresh
true to repaint even while a ModernWindowChromeProvider is in the middle of drawing; the window is also re-laid out at its current size.

SetBoundsCore

protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)

Sets the bounds of this control, applying the constraints it imposes on its own size.

SetClientSizeCore

protected override void SetClientSizeCore(int x, int y)

Sets the client size, allowing for the custom chrome, so that asking for a client area of a given size actually yields one.

Parameters
x
The requested client width.
y
The requested client height.

UpdateWindowTitleText

public void UpdateWindowTitleText(string titlebarText)

Sets the caption and repaints the title bar at once.

Parameters
titlebarText
The new caption.

WndProc

protected override void WndProc(ref Message m)

Processes the Windows messages sent to this control's window.

Events

WindowChromeBorderSizeChanged

public event EventHandler<WindowChromeTitlebarHeightChangedEventArgs> WindowChromeBorderSizeChanged

Occurs when ChromeBorderSize changes.

Remarks

WindowChromeThemeChanged

public event EventHandler<WindowChromeThemeChangedEventArgs> WindowChromeThemeChanged

Occurs when WindowChromeTheme is set, after the theme's colours have been applied and before the chrome is repainted.

Remarks

Raised even when the theme set is the one already in use.

WindowChromeTitlebarHeightChanged

public event EventHandler<WindowChromeTitlebarHeightChangedEventArgs> WindowChromeTitlebarHeightChanged

Occurs when ChromeTitlebarHeight changes, after the window has been resized for it.

WindowCloseRequested

public event EventHandler WindowCloseRequested

Occurs when the user clicks the close button.

Remarks

While this event has a handler the window does not close itself: call Form.Close in the handler to close it. Alt+F4 still closes the window as usual, through Form.FormClosing.

Example
WindowCloseRequested += (sender, e) =>
{
    if (!document.IsDirty || ConfirmDiscard())
    {
        Close();
    }
};

WindowIconClicked

public event EventHandler<WindowIconClickEventArgs> WindowIconClicked

Occurs when the user clicks the window icon at the left of the title bar.

WindowMinimizeRequested

public event EventHandler WindowMinimizeRequested

Occurs when the user clicks the minimise button.

Remarks

While this event has a handler the window does not minimise itself: set Form.WindowState in the handler.

WindowRestoreOrMaximizeRequested

public event EventHandler WindowRestoreOrMaximizeRequested

Occurs when the user clicks the maximise/restore button, or double-clicks the title bar.

Remarks

While this event has a handler the window does not change state itself: set Form.WindowState in the handler.

WindowStateChanged

public event EventHandler<WindowStateChangedEventArgs> WindowStateChanged

Occurs when the window is minimised, maximised or restored, with the state before and after.