ModernChromeWindow
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 | |
|---|---|
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 | Gets or sets extra space before the window icon at the left of the title bar. |
BackgroundBrush | Gets or sets the brush the content area is painted with while
IsFormBackgroundPaintingInLinearGradientModeEnabled is on. |
BackgroundDisabledCloseCommandButton | Gets or sets the brush the close button is filled with while the buttons are disabled (IsControlBoxEnabled off). |
BackgroundDisabledMaximizeRestoreCommandButton | Gets or sets the brush the maximise/restore button is filled with while the buttons are disabled (IsControlBoxEnabled off). |
BackgroundDisabledMinimizeCommandButton | Gets or sets the brush the minimise button is filled with while the buttons are disabled (IsControlBoxEnabled off). |
BackgroundHotCloseCommandButton | Gets or sets the brush the close button is filled with while the pointer is over it. |
BackgroundHotMaximizeRestoreCommandButton | Gets or sets the brush the maximise/restore button is filled with while the pointer is over it. |
BackgroundHotMinimizeCommandButton | Gets or sets the brush the minimise button is filled with while the pointer is over it. |
BackgroundNormalCloseCommandButton | Gets or sets the brush the close button is filled with at rest. |
BackgroundNormalMaximizeRestoreCommandButton | Gets or sets the brush the maximise/restore button is filled with at rest. |
BackgroundNormalMinimizeCommandButton | Gets or sets the brush the minimise button is filled with at rest. |
BackgroundPressedCloseCommandButton | Gets or sets the brush the close button is filled with while it is held down. |
BackgroundPressedMaximizeRestoreCommandButton | Gets or sets the brush the maximise/restore button is filled with while it is held down. |
BackgroundPressedMinimizeCommandButton | Gets or sets the brush the minimise button is filled with while it is held down. |
BorderColorDisabledCloseCommandButton | Gets or sets the colour of the close button's outline while the buttons are disabled (IsControlBoxEnabled off). |
BorderColorDisabledMaximiseRestoreCommandButton | Gets or sets the colour of the maximise/restore button's outline while the buttons are disabled (IsControlBoxEnabled off). |
BorderColorDisabledMinimizeCommandButton | Gets or sets the colour of the minimise button's outline while the buttons are disabled (IsControlBoxEnabled off). |
BorderColorHotCloseCommandButton | Gets or sets the colour of the close button's outline while the pointer is over it. |
BorderColorHotMaximiseRestoreCommandButton | Gets or sets the colour of the maximise/restore button's outline while the pointer is over it. |
BorderColorHotMinimizeCommandButton | Gets or sets the colour of the minimise button's outline while the pointer is over it. |
BorderColorNormalCloseCommandButton | Gets or sets the colour of the close button's outline at rest. |
BorderColorNormalMaximiseRestoreCommandButton | Gets or sets the colour of the maximise/restore button's outline at rest. |
BorderColorNormalMinimizeCommandButton | Gets or sets the colour of the minimise button's outline at rest. |
BorderColorPressedCloseCommandButton | Gets or sets the colour of the close button's outline while it is held down. |
BorderColorPressedMaximiseRestoreCommandButton | Gets or sets the colour of the maximise/restore button's outline while it is held down. |
BorderColorPressedMinimizeCommandButton | Gets or sets the colour of the minimise button's outline while it is held down. |
ChromeBorderSize | Gets or sets the width of the border round the window, which is also the strip the user drags to resize it. |
ChromeTitlebarHeight | Gets or sets the height of the title bar. |
CloseCommandDisabledButtonImage | Gets or sets a picture drawn in place of the close button while the buttons are disabled (IsControlBoxEnabled off). |
CloseCommandNormalButtonImage | Gets or sets a picture drawn in place of the close button at rest. |
CloseCommandOnHoverButtonImage | Gets or sets a picture drawn in place of the close button while the pointer is over it. |
CloseCommandOnPushedButtonImage | Gets or sets a picture drawn in place of the close button while it is held down. |
ContainerChild | Gets or sets the panel that holds the window's content, for ShouldEnableContainerChildAutoManagement. |
CreateParams | Gets the parameters used to create this control's window, with the window styles this control needs added to them. |
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. |
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 | Gets or sets whether clicking the window's taskbar button minimises it, and clicking again restores it, as with a standard window. |
EnableMinimizeRestoreAnimation | Gets or sets whether Windows animates the window as it is minimised and restored. |
ForegroundInternalVisualForDisabledCloseCommandButton | Gets or sets the colour of the symbol on the close button while the buttons are disabled (IsControlBoxEnabled off). |
ForegroundInternalVisualForDisabledMaximizeRestoreCommandButton | Gets or sets the colour of the symbol on the maximise/restore button while the buttons are disabled (IsControlBoxEnabled off). |
ForegroundInternalVisualForDisabledMinimizeCommandButton | Gets or sets the colour of the symbol on the minimise button while the buttons are disabled (IsControlBoxEnabled off). |
ForegroundInternalVisualForHotCloseCommandButton | Gets or sets the colour of the symbol on the close button while the pointer is over it. |
ForegroundInternalVisualForHotMaximizeRestoreCommandButton | Gets or sets the colour of the symbol on the maximise/restore button while the pointer is over it. |
ForegroundInternalVisualForHotMinimizeCommandButton | Gets or sets the colour of the symbol on the minimise button while the pointer is over it. |
ForegroundInternalVisualForNormalCloseCommandButton | Gets or sets the colour of the symbol on the close button at rest. |
ForegroundInternalVisualForNormalMaximizeRestoreCommandButton | Gets or sets the colour of the symbol on the maximise/restore button at rest. |
ForegroundInternalVisualForNormalMinimizeCommandButton | Gets or sets the colour of the symbol on the minimise button at rest. |
ForegroundInternalVisualForPressedCloseCommandButton | Gets or sets the colour of the symbol on the close button while it is held down. |
ForegroundInternalVisualForPressedMaximizeRestoreCommandButton | Gets or sets the colour of the symbol on the maximise/restore button while it is held down. |
ForegroundInternalVisualForPressedMinimizeCommandButton | Gets or sets the colour of the symbol on the minimise button while it is held down. |
FormBorderStyle | Gets the border style, which is always None: the window draws its
own frame. |
GapBetweenCommandButtons | Gets or sets the space between the minimise, maximise and close buttons. |
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. |
IsBorderDrawnWhenWindowIsMaximised | Gets or sets whether a maximised window keeps its border. |
IsCloseBoxVisible | Gets or sets whether the close button is shown. |
IsControlBoxEnabled | Gets or sets whether the minimise, maximise/restore and close buttons respond; off, they are drawn disabled. |
IsDoubleClickOnTitlebarActionResultingInWindowStateChangeEnabled | Gets or sets whether double-clicking the title bar maximises or restores the window. |
IsFormBackgroundPaintingInLinearGradientModeEnabled | Gets or sets whether the content area is painted with BackgroundBrush instead of
Control.BackColor. |
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. |
IsLocationAutoResettingAnchoredControlsEnabled | Not used: setting it only repaints the window and its chrome. |
IsTitlebarAndBorderBackgroundTransparent | Gets or sets whether the title bar background is see-through, like IsTitlebarBackgroundTransparent. |
IsTitlebarBackgroundTransparent | Gets or sets whether the title bar background is see-through, so whatever is behind the window shows through it. |
IsWindowControlBoxCommandsAutoCodeExecutionEnabled | Gets or sets whether the minimise, maximise/restore and close buttons act on the window by themselves when they have no event handler. |
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. |
IsWindowResizingAllowed | Gets or sets whether the user can resize the window by dragging its border. |
MaximizeCommandDisabledButtonImage | Gets or sets a picture drawn in place of the maximise button while the buttons are disabled (IsControlBoxEnabled off). |
MaximizeCommandNormalButtonImage | Gets or sets a picture drawn in place of the maximise button at rest. |
MaximizeCommandOnHoverButtonImage | Gets or sets a picture drawn in place of the maximise button while the pointer is over it. |
MaximizeCommandOnPushedButtonImage | Gets or sets a picture drawn in place of the maximise button while it is held down. |
MinimizeCommandDisabledButtonImage | Gets or sets a picture drawn in place of the minimise button while the buttons are disabled (IsControlBoxEnabled off). |
MinimizeCommandNormalButtonImage | Gets or sets a picture drawn in place of the minimise button at rest. |
MinimizeCommandOnHoverButtonImage | Gets or sets a picture drawn in place of the minimise button while the pointer is over it. |
MinimizeCommandOnPushedButtonImage | Gets or sets a picture drawn in place of the minimise button while it is held down. |
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. |
RestoreCommandDisabledButtonImage | Gets or sets a picture drawn in place of the restore button while the buttons are disabled (IsControlBoxEnabled off). |
RestoreCommandNormalButtonImage | Gets or sets a picture drawn in place of the restore button at rest. |
RestoreCommandOnHoverButtonImage | Gets or sets a picture drawn in place of the restore button while the pointer is over it. |
RestoreCommandOnPushedButtonImage | Gets or sets a picture drawn in place of the restore button while it is held down. |
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. |
ShouldAutoResizeWindowHeightOnTitlebarHeightChange | Gets or sets whether the window grows or shrinks with ChromeTitlebarHeight, so the content area keeps
its height. |
ShouldAutoResizeWindowSizeOnBorderWidthChange | Gets or sets whether the window grows or shrinks with ChromeBorderSize, so the content area keeps its
size. |
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. |
ShouldDrawBorderForWindowChromeCommandButtons | Gets or sets whether the minimise, maximise and close buttons are outlined, in the border colours for each state. |
ShouldDrawResizeGripper | Not used: no resize grip is drawn. |
ShouldDrawWindowCommandButtonsOnTopRightEdgeIgnoringBorderSizeWhenInMaximizedMode | Not used: the built-in drawing places the command buttons itself. |
ShouldDrawWindowEdgesWithRoundedCorners | Gets or sets whether the window's corners are rounded. |
ShouldEnableContainerChildAutoManagement | Gets or sets whether ContainerChild is made to fill the content area and size itself to its content. |
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. |
ShouldMaximizedWindowStateCoverTaskbarArea | Gets or sets whether a maximised window covers the taskbar, as a full-screen application does. |
ShouldRefreshChildrenWhenRepaintingNonClientArea | Gets or sets whether the window's controls are repainted each time the title bar and border are. |
ShouldRefreshClientAreaUponMaximizedWindowState | Gets or sets whether the content area is repainted when the window is maximised. |
ShouldRefreshNcAreaWhenInDesignMode | Gets or sets whether the title bar and border are repainted in the Visual Studio designer. |
ShouldRefreshNonClientAreaWithDockedChildControls | Gets or sets whether the designer repaints the title bar and border when docked child controls change the layout. |
ShouldRenderAppIcon | Gets or sets whether the window icon is drawn at the left of the title bar. |
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. |
ShouldRenderAppTitlebarText | Gets or sets whether the caption is drawn in the title bar. |
ShouldRenderWindowCommandButtonsInsideChromeBorderWhenInNormalWindowState | Not used: the built-in drawing places the command buttons itself. |
ShouldRepaintNonClientAreaWhenWindowIsBeingResized | Gets or sets whether the title bar and border are repainted continuously while the user drags the window's size. |
ShouldRunBaseCore | For the window's own message handling: whether the standard window procedure runs for the message being handled. |
TitleTextDrawingFormat | Gets or sets how the caption is laid out in the title bar. |
TitlebarControls | Gets (and helps set up) the child controls to be hosted on the title bar. |
TitlebarControlsHostLocation | Gets or sets where the controls hosted in the title bar sit, in title bar coordinates. |
TitlebarControlsHostLocationMaximumXOffset | Gets the furthest right the hosted title bar controls can start, clear of the command buttons. |
TitlebarControlsHostLocationMaximumYOffset | Gets the lowest the hosted title bar controls can sit while staying inside the title bar. |
TitlebarControlsHostMaximumWidth | Gets the widest the area for hosted title bar controls can be, leaving room for the command buttons. |
TitlebarControlsHostSize | Gets or sets the size of the area in the title bar that holds hosted controls. |
TitlebarText | Gets or sets the caption drawn in the title bar. |
TopMarginForDrawingWindowChromeCommandButtons | Gets or sets a top margin for the command buttons, kept no larger than the title bar allows. |
Window | Gets this window, for an IModernWindowChromeProvider that draws its chrome. |
WindowChromeBorderColor | Gets or sets the colour of the border round the window. |
WindowChromeCommandButtonSize | Gets or sets the size of each of the minimise, maximise and close buttons. |
WindowChromeEndColor | Gets or sets the second colour of the title bar's gradient. |
WindowChromeGradientMode | Gets or sets the direction of the title bar's gradient from WindowChromeStartColor to
WindowChromeEndColor. |
WindowChromeStartColor | Gets or sets the first colour of the title bar's background, also used for the border while
WindowChromeBorderColor is empty. |
WindowChromeTheme | Gets or sets the built-in look of the title bar, border and command buttons. |
WindowChromeTitleTextBrush | Gets or sets the brush the caption is drawn with. |
WindowChromeTitleTextBrushWhenTitlebarBackgroundIsTransparent | Gets or sets the brush the caption is drawn with while IsTitlebarBackgroundTransparent is on. |
WindowChromeTitleTextFont | Gets or sets the font of the caption. |
WindowContextMenu | Gets or sets the shortcut menu shown when the user right-clicks the title bar. |
WindowContextMenuCloseCommandImage | Gets or sets the picture beside the Close command on the title bar's shortcut menu. |
WindowContextMenuCloseCommandTitle | Gets or sets the text of the Close command on the title bar's shortcut menu. |
WindowContextMenuMaximizeCommandImage | Gets or sets the picture beside the Maximize command on the title bar's shortcut menu. |
WindowContextMenuMaximizeCommandTitle | Gets or sets the text of the Maximize command on the title bar's shortcut menu. |
WindowContextMenuMinimizeCommandImage | Gets or sets the picture beside the Minimize command on the title bar's shortcut menu. |
WindowContextMenuMinimizeCommandTitle | Gets or sets the text of the Minimize command on the title bar's shortcut menu. |
WindowContextMenuRestoreCommandImage | Gets or sets the picture beside the Restore command on the title bar's shortcut menu. |
WindowContextMenuRestoreCommandTitle | Gets or sets the text of the Restore command on the title bar's shortcut menu. |
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. |
WindowEdgeCornerRadius | Gets or sets how far the window's corners are rounded, while ShouldDrawWindowEdgesWithRoundedCorners
is on. |
| Methods | |
Dispose | Releases the resources held by this ModernChromeWindow. |
OnActivated | Raises the Activated event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior. |
OnClientSizeChanged | Raises the ClientSizeChanged event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior. |
OnClosed | Raises the Closed event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior. |
OnClosing | Raises the Closing event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior. |
OnDeactivate | Raises the Deactivate event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior. |
OnDpiChanged | 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. |
OnFormClosing | Raises the FormClosing event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior. |
OnHandleCreated | Raises the HandleCreated event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior. |
OnKeyDown | Raises the KeyDown event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior. |
OnKeyUp | Raises the KeyUp event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior. |
OnLoad | Raises the Load event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior. |
OnMouseMove | Raises the MouseMove event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior. |
OnMouseUp | Raises the MouseUp event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior. |
OnPaint | Raises the Paint event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior. |
OnPaintBackground | Raises the PaintBackground event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior. |
OnShown | Raises the Shown event. ModernChromeWindow overrides it so the control's own handling runs alongside the base behavior. |
OnVisibleChanged | Raises 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. // |
PositionAndSizeWindow | Sets where the window appears and how big it is, applied when the window is first shown – or at once. |
ProcessCmdKey | Gives this control first sight of a command key, before the menu system and the parent form see it. |
RefreshWindowNonClient | Repaints the title bar and border. |
SetBoundsCore | Sets the bounds of this control, applying the constraints it imposes on its own size. |
SetClientSizeCore | Sets the client size, allowing for the custom chrome, so that asking for a client area of a given size actually yields one. |
UpdateWindowTitleText | Sets the caption and repaints the title bar at once. |
WndProc | Processes the Windows messages sent to this control's window. |
| Events | |
WindowChromeBorderSizeChanged | Occurs when ChromeBorderSize changes. |
WindowChromeThemeChanged | Occurs when WindowChromeTheme is set, after the theme's colours have been applied and before the
chrome is repainted. |
WindowChromeTitlebarHeightChanged | Occurs when ChromeTitlebarHeight changes, after the window has been resized for it. |
WindowCloseRequested | Occurs when the user clicks the close button. |
WindowIconClicked | Occurs when the user clicks the window icon at the left of the title bar. |
WindowMinimizeRequested | Occurs when the user clicks the minimise button. |
WindowRestoreOrMaximizeRequested | Occurs when the user clicks the maximise/restore button, or double-clicks the title bar. |
WindowStateChanged | Occurs when the window is minimised, maximised or restored, with the state before and after. |
Constructors
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
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
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
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
BackgroundNormalCloseCommandButton
Gets or sets the brush the close button is filled with at rest.
- Value
- Set by each built-in
WindowChromeTheme; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
BackgroundNormalMaximizeRestoreCommandButton
Gets or sets the brush the maximise/restore button is filled with at rest.
- Value
- Set by each built-in
WindowChromeTheme; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
BackgroundNormalMinimizeCommandButton
Gets or sets the brush the minimise button is filled with at rest.
- Value
- Set by each built-in
WindowChromeTheme; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
BackgroundPressedCloseCommandButton
Gets or sets the brush the close button is filled with while it is held down.
- Value
- Set by each built-in
WindowChromeTheme; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
BackgroundPressedMinimizeCommandButton
Gets or sets the brush the minimise button is filled with while it is held down.
- Value
- Set by each built-in
WindowChromeTheme; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
Remarks
Drawn while ShouldDrawBorderForWindowChromeCommandButtons is on.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
Remarks
Drawn while ShouldDrawBorderForWindowChromeCommandButtons is on.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
Remarks
Drawn while ShouldDrawBorderForWindowChromeCommandButtons is on.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
Remarks
Drawn while ShouldDrawBorderForWindowChromeCommandButtons is on.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
Remarks
Drawn while ShouldDrawBorderForWindowChromeCommandButtons is on.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
Remarks
Drawn while ShouldDrawBorderForWindowChromeCommandButtons is on.
BorderColorNormalCloseCommandButton
Gets or sets the colour of the close button's outline at rest.
- Value
- Set by each built-in
WindowChromeTheme; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
Remarks
Drawn while ShouldDrawBorderForWindowChromeCommandButtons is on.
BorderColorNormalMaximiseRestoreCommandButton
Gets or sets the colour of the maximise/restore button's outline at rest.
- Value
- Set by each built-in
WindowChromeTheme; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
Remarks
Drawn while ShouldDrawBorderForWindowChromeCommandButtons is on.
BorderColorNormalMinimizeCommandButton
Gets or sets the colour of the minimise button's outline at rest.
- Value
- Set by each built-in
WindowChromeTheme; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
Remarks
Drawn while ShouldDrawBorderForWindowChromeCommandButtons is on.
BorderColorPressedCloseCommandButton
Gets or sets the colour of the close button's outline while it is held down.
- Value
- Set by each built-in
WindowChromeTheme; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
Remarks
Drawn while ShouldDrawBorderForWindowChromeCommandButtons is on.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
Remarks
Drawn while ShouldDrawBorderForWindowChromeCommandButtons is on.
BorderColorPressedMinimizeCommandButton
Gets or sets the colour of the minimise button's outline while it is held down.
- Value
- Set by each built-in
WindowChromeTheme; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
Remarks
Drawn while ShouldDrawBorderForWindowChromeCommandButtons is on.
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
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
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
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
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
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
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
Gets the parameters used to create this control's window, with the window styles this control needs added to them.
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
The area inside the window available to its content, which is the client area less the custom chrome this window draws for itself.
EnableMinimizeRestoreActionUponTaskbarIconClick
Gets or sets whether clicking the window's taskbar button minimises it, and clicking again restores it, as with a standard window.
- Value
trueto allow it; the default istrue.
Remarks
Read when the window's handle is created: set it in the designer or the constructor, not later.
EnableMinimizeRestoreAnimation
Gets or sets whether Windows animates the window as it is minimised and restored.
- Value
trueto animate; the default isfalse.
Remarks
Read when the window's handle is created: set it in the designer or the constructor, not later.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
ForegroundInternalVisualForNormalCloseCommandButton
Gets or sets the colour of the symbol on the close button at rest.
- Value
- Set by each built-in
WindowChromeTheme; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
ForegroundInternalVisualForNormalMaximizeRestoreCommandButton
Gets or sets the colour of the symbol on the maximise/restore button at rest.
- Value
- Set by each built-in
WindowChromeTheme; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
ForegroundInternalVisualForNormalMinimizeCommandButton
Gets or sets the colour of the symbol on the minimise button at rest.
- Value
- Set by each built-in
WindowChromeTheme; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
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; setWindowChromeThemetoWindowChromeTheme.Custombefore your own, or a theme chosen later replaces it.
FormBorderStyle
Gets the border style, which is always None: the window draws its
own frame.
- Value
- Always
None; any other value is ignored. UseChromeBorderSizeandIsWindowResizingAllowedto change the frame.
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
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
Gets or sets whether a maximised window keeps its border.
- Value
trueto keep it; the default istrue. Off, a maximised window's content reaches the screen edges.
IsCloseBoxVisible
Gets or sets whether the close button is shown.
- Value
trueto show it; the default istrue.
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
Gets or sets whether the minimise, maximise/restore and close buttons respond; off, they are drawn disabled.
- Value
trueto enable them; the default istrue.
Remarks
To hide the buttons rather than disable them, use Form.MinimizeBox,
Form.MaximizeBox and IsCloseBoxVisible.
IsDoubleClickOnTitlebarActionResultingInWindowStateChangeEnabled
Gets or sets whether double-clicking the title bar maximises or restores the window.
- Value
trueto allow it; the default istrue.
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
Gets or sets whether the content area is painted with BackgroundBrush instead of
Control.BackColor.
- Value
trueto use the brush; the default isfalse.
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
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
truefor a border-only window; the default isfalse.
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
Not used: setting it only repaints the window and its chrome.
- Value
- The default is
true. Kept for compatibility.
IsTitlebarAndBorderBackgroundTransparent
Gets or sets whether the title bar background is see-through, like IsTitlebarBackgroundTransparent.
- Value
truefor a see-through title bar; the default isfalse.
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
Gets or sets whether the title bar background is see-through, so whatever is behind the window shows through it.
- Value
truefor a see-through title bar; the default isfalse.
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
Gets or sets whether the minimise, maximise/restore and close buttons act on the window by themselves when they have no event handler.
- Value
trueto let them act; the default istrue.
Remarks
Off, a button with no WindowMinimizeRequested, WindowRestoreOrMaximizeRequested
or WindowCloseRequested handler does nothing.
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
trueto lock it; the default isfalse.
IsWindowResizingAllowed
Gets or sets whether the user can resize the window by dragging its border.
- Value
trueto allow it; the default istrue.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
trueto keep them at the right; the default isfalse.
ShouldAutoResizeWindowHeightOnTitlebarHeightChange
Gets or sets whether the window grows or shrinks with ChromeTitlebarHeight, so the content area keeps
its height.
- Value
trueto resize the window; the default istrue.
Remarks
Off, the window keeps its size and the content area absorbs the change.
ShouldAutoResizeWindowSizeOnBorderWidthChange
Gets or sets whether the window grows or shrinks with ChromeBorderSize, so the content area keeps its
size.
- Value
trueto resize the window; the default istrue.
Remarks
Off, the window keeps its size and the content area absorbs the change.
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
trueto repeat it; the window sets it totruewhen it is created.
Remarks
Used while ShouldEnableWindowsKeyHooks is on.
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
Not used: no resize grip is drawn.
- Value
- The default is
false. Kept for compatibility.
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
Gets or sets whether the window's corners are rounded.
- Value
truefor rounded corners; the default isfalse.
Remarks
Each built-in WindowChromeTheme turns it off, so set it after the theme.
See also
ShouldEnableContainerChildAutoManagement
Gets or sets whether ContainerChild is made to fill the content area and size itself to its content.
- Value
trueto manage it; the default isfalse.
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
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
trueto handle them; the default isfalse.
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
Gets or sets whether a maximised window covers the taskbar, as a full-screen application does.
- Value
trueto cover it; the default isfalse, which keeps a maximised window to the screen's working area.
ShouldRefreshChildrenWhenRepaintingNonClientArea
Gets or sets whether the window's controls are repainted each time the title bar and border are.
- Value
trueto repaint them; the default istrue.
Remarks
Turn it off only if repainting the content is slow and it shows no artefacts without it.
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
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
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
Gets or sets whether the window icon is drawn at the left of the title bar.
- Value
trueto draw it; the default istrue.
See also
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
truefor the standard size; the default istrue.
ShouldRenderAppTitlebarText
Gets or sets whether the caption is drawn in the title bar.
- Value
trueto draw it; the default istrue.
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
Gets or sets whether the title bar and border are repainted continuously while the user drags the window's size.
- Value
trueto repaint during the drag; the default isfalse, which repaints when the drag ends.
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
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
Gets (and helps set up) the child controls to be hosted on the title bar.
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
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
Gets the lowest the hosted title bar controls can sit while staying inside the title bar.
- Value
- In pixels; it changes with
ChromeTitlebarHeight.
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
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
TitlebarControlsHostMaximumWidthand no taller than the title bar less the border. A width or height of 0 takes the largest allowed.
TitlebarText
Gets or sets the caption drawn in the title bar.
- Value
- The window's text.
See also
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.Customsets 3.
Remarks
The built-in drawing places the buttons itself and does not read this value, so changing it only repaints the chrome.
Window
Gets this window, for an IModernWindowChromeProvider that draws its chrome.
WindowChromeBorderColor
Gets or sets the colour of the border round the window.
- Value
- Set by each built-in
WindowChromeTheme.Color.Emptydraws the border inWindowChromeStartColor.
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
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 asWindowChromeStartColor.
WindowChromeGradientMode
Gets or sets the direction of the title bar's gradient from WindowChromeStartColor to
WindowChromeEndColor.
- Value
- The default is
Vertical.
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
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
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
Gets or sets the brush the caption is drawn with while IsTitlebarBackgroundTransparent is on.
- Value
- The default is a
BrushContainerinColor.SlateGray.
See also
WindowChromeTitleTextFont
Gets or sets the font of the caption.
- Value
- The default is the window's font family at 10 points, bold.
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
Each change raises Control.LocationChanged and Control.SizeChanged.
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
Releases the resources held by this ModernChromeWindow.
Parameters
disposing- true when called from
Dispose; false when called from the finalizer.
OnActivated
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
// Gets or sets the color of the window chrome title bar border. //
See also
PositionAndSizeWindow
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.
performActionNowtrueto 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
Gives this control first sight of a command key, before the menu system and the parent form see it.
RefreshWindowNonClient
Repaints the title bar and border.
Parameters
shouldPerformExtendedRefreshtrueto repaint even while aModernWindowChromeProvideris in the middle of drawing; the window is also re-laid out at its current size.
SetBoundsCore
Sets the bounds of this control, applying the constraints it imposes on its own size.
SetClientSizeCore
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
Sets the caption and repaints the title bar at once.
Parameters
titlebarText- The new caption.
WndProc
Processes the Windows messages sent to this control's window.
Events
WindowChromeBorderSizeChanged
Occurs when ChromeBorderSize changes.
Remarks
The event data's WindowChromeTitlebarHeightChangedEventArgs.PreviousHeight and
WindowChromeTitlebarHeightChangedEventArgs.NewHeight carry the old and new border sizes.
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
Occurs when ChromeTitlebarHeight changes, after the window has been resized for it.
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
Occurs when the user clicks the window icon at the left of the title bar.
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
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
Occurs when the window is minimised, maximised or restored, with the state before and after.