Custom title bar
ExTitleBar placed directly on an ExForm replaces the system caption like in JetBrains Rider or Visual Studio. It
shows the window icon with the system menu on the left, the window buttons on the right and your controls, typically
the main MenuStrip, between them. The form text fills the free space. The system frame stays, so the window keeps its
shadow, Aero Snap, Snap Layouts and animations.
Adding the title bar
Drop an ExTitleBar from the toolbox on an ExForm and move the main menu into it, or do the same in code:
var titleBar = new ExTitleBar();
Controls.Remove(mainMenu);
mainMenu.Dock = DockStyle.Left; // the form text fills the space after the menu
mainMenu.LayoutStyle = ToolStripLayoutStyle.HorizontalStackWithOverflow;
titleBar.Controls.Add(mainMenu);
Controls.Add(titleBar); // docked to the top
MainMenuStrip = mainMenu;
The title bar is always docked to the top of the form. Only the first ExTitleBar among the direct children of the
form replaces the caption. A menu docked to the left leaves the rest of the title bar for the form text; a menu docked
to the top would cover it.
Where it works
- Windows 10 and newer with any
FormBorderStyleexceptNone. WithNone, or on older systems (ExTools.SupportsCustomTitleBar), the title bar is a plain panel without the icon, text and buttons.ExForm.UsesCustomTitleBartells which case applies. - Window buttons and the icon follow
ControlBox,MinimizeBox,MaximizeBox,HelpButton,ShowIconand tool windows like the system caption. The help button shows only without the minimize and maximize buttons, a tool window has only the close button and a dialog (FixedDialog) without its own icon has no icon.
Colors
- An active window shows the accent color when Windows shows it on title bars (Settings, Personalization, Colors, "Show accent color on title bars and window borders").
ExForm.TitleBarBackColorandTitleBarForeColortake precedence over the accent color and the theme.ExForm.TitleBarBorderColorandCornersTypework as with the system caption.FormStyle(Mica and other backdrops) shows only in the system caption.- A theme gives the title bar the panel colors (
PanelBackColor,PanelForeColor) and applies itself to the controls in the title bar.ExTitleBar.InactiveForeColor,ButtonHoverBackColor,ButtonPressedBackColor,CloseButtonHoverBackColorandTopBorderColorset the remaining colors.
Tool strips placed directly in the title bar get a transparent background and the caption text color, other controls
keep their colors. In an inactive window the items of these tool strips are dimmed through ToolStripItem.ForeColor,
so a renderer that picks the text color of items itself won't show the dimming.
Menu and dragging
- Empty parts of tool strips placed directly in the title bar drag the window, their items stay clickable. Other controls in the title bar are clickable as a whole.
- A
MenuStripcollapses at runtime into a single ☰ button when its items don't fit (ExTitleBar.CollapseMenu, on by default). The items move under the button, other items of the menu stay. ExTitleBar.HitTest(point)returns the part of the title bar at a point (TitleBarHit), which decides what Windows does with the mouse there.
Designer and DPI
The designer shows the form without the system caption and frame. At runtime the window has the system frame only on the
left, right and bottom. The designed ClientSize is the same in both, and DPI scaling scales it without the caption.
Composited painting
ExForm.UseCompositedPainting (WS_EX_COMPOSITED, on by default) paints the whole form double buffered, which reduces
flicker when resizing. An empty TextBox with PlaceholderText repaints such a form endlessly, use
ExTextBox.HintText instead or turn composited painting off.


