A lightweight helper that replaces WinForms’ classic window chrome with a flat, theme‑able title‑bar, rounded corners, and fully‑custom minimise / maximise / close buttons. Drop it into any Form, call one line of code, and instantly modernise your UI.
- It’s part of Core Keepers Workshop and is released under the GNU GPL v3.
- Also check out the BorderlessTabControl.
| Feature | Details |
|---|---|
| Flat Title‑Bar | Removes the native chrome and draws a sleek, minimal bar that blends with your app theme. |
| Dark / Light Themes | One‑liner switch between dark and light palettes. |
| Rounded Corners | Pick any combination (Corner flag enum) and radius—independent of OS support. |
| Custom Buttons | Built‑in Min, Max, Close (and optional Help) buttons with glyphs you can restyle. |
| Border Options | Draw borders inside (Grow In) or outside (Grow Out) of the client area; choose size & colour. |
| Runtime Updates | Call UpdateStyle(...) to tweak theme, radius, border, etc. without recreation. |
| Drag Anywhere | Drag the window by the custom bar—implemented via a tiny Win32 interop helper. |
| Extension Helpers | Form.ApplyTheme() & RefreshAllThemes() wire everything up and keep multiple windows in sync. |
- Copy
TitleBarManager.cs(or rename) into your WinForms project. - Change the namespace if necessary.
- Re‑build; no designer support is needed—the styler is code‑only.
ℹ️ No NuGet package (yet) – just a single self‑contained file.
public partial class MainForm : Form
{
private CustomFormStyler _styler;
public MainForm()
{
InitializeComponent();
_styler = new CustomFormStyler(this);
_styler.Enable(); // Apply the custom chrome.
}
}// Using the helper in FormStylingExtensions:
Load += (_, __) => this.ApplyTheme();| Member | Description |
|---|---|
Enable() / Disable() |
Replace or restore the native window chrome. |
Toggle() |
Convenience wrapper that flips the state. |
IsEnabled |
bool – current state of the styler. |
UpdateStyle(...) |
Change any subset of options at runtime (theme, border size, radius, etc.). |
CloseButtonPressed |
bool – becomes true the moment the user presses Close (handy for confirmation logic). |
| Parameter (UpdateStyle) | Type | Notes |
|---|---|---|
theme |
ThemeMode |
Dark / Light. |
borderMode |
BorderMode |
GrowOut (outside) or GrowIn (inside). |
roundedCorners |
Corner |
Flag enum (TopLeft, BottomRight, … All). |
borderColor |
Color? |
null ➜ auto (white on dark, black on light). |
titleBarHeight |
int |
Pixel height of the bar. |
cornerRadius |
int |
Radius in pixels. 0 ➜ square. |
borderSize |
int |
Stroke width in pixels. 0 ➜ no border. |
showIcon |
bool |
Show/hide the small window icon. |
- Change theme at runtime – flip a checkbox, then call
RefreshAllThemes()to apply the new dark/light palette across every open window. - Per‑window overrides – call
UpdateStyle()on a specific styler to deviate from global settings. - Help button behaviour – if your form’s
HelpButtonproperty istrueand both maximise & minimise are hidden, a “?” glyph appears automatically. - Corner selection UI – expose four checkboxes and build a
Cornermask on the fly (seeMainForm.SelectedCorners). - Border insets – remember:
GrowOutchanges overall form size, whileGrowIneats into the client area; pick what suits your layout.
FormBorderStyle = None– strips the OS frame so we get a blank canvas.- Client‑area expansion – compensates for the new title‑bar height (and optional GrowOut border) to keep your existing controls untouched.
- Wrapper panel – all pre‑existing controls are moved into a
_contentPanelso resizing the bar never upsets user content. - Drag support – a quick call to
ReleaseCapture()+SendMessage(WM_NCLBUTTONDOWN, HTCAPTION)makes the new bar draggable. - Rounded corners –
GraphicsPath+Regionlet us clip the rectangle to any combination of rounded edges. - Custom border paint – drawn in
Form_Paint; half‑pixel offsets ensure crisp strokes at any width.
TitleBarManager.cs / CustomFormStyler is licensed under GNU General Public License v3.0.
See the root LICENSE file for the full text.
Original author: RussDev7
Inspired by countless WinForms custom‑chrome experiments shared by the community.
Found a bug or have an idea? Open an issue or pull request—contributions welcome!

