ModernChromeWindow .NET

for  WinForms
  • Custom Window Chrome (Title bar, Border frame) .NET control / component for WinForms .NET
  • Supports hosting custom controls on the title bar area (non-client area)
  • Supports very deep customizations: Includes setting up border size, titlebar height, button size, etc.
  • Out-of-the-box themes includes: MS Office, Win8 & WinRT style rendering
  • Supports plugging-in your own custom chrome render provider (an "advanced" feature)

Essentially, with this component, you will be able to build heavily customized custom title bar / custom caption bar / custom border form based applications for Winforms!

 

Overview

 

 

ModernChromeWindow .NET is a highly customizable WinForms .NET Form window component that lets you present your WinForms .NET application window(s) in a variety of modern looking Window styles – i.e. Microsoft Office, Windows 8, and WinRT, and even in a custom style of your own by simply supplying your own values for various properties that the component exposes.

 

 

 

 

 

 

Why Would I Use It?

 

 

If you wanted to move away from using the traditional looking Windows Form user-interface, and wanted your applications to have a modern look-and-feel, and at the same time you do not want to handle the complex low-level non-client area Win32 messages yourself, then you would want to use this component.

 

 

Essentially, with this component, you will be able to build heavily customized custom title bar / custom caption bar / custom border form based applications for Winforms, without you having to deal with the various complex low-level Win32 (non-client area) messages.

 

 

 

How It Works?

 

 

This component inherits from the standard .NET Form class, and makes it border-less, and draws all of its non-client sections of its UI on its own.

 

In this process, the component also exposes a variety of simple to set CLR properties that it uses to draw and style the Window chrome, so that you can customize it the way you want it to look, in addition to keeping the standard behaviors of the WinForms .NET Form class.

 

The component provides a set of themes right out-of-the-box, ready to use, with the likes of Microsoft Office (with various color themes as well), Win8 & WinRT (a.k.a Metro) styles.

 

 

 

What More?

 

 

1.  Ability to host .NET controls on the title bar section

 

You can even host custom controls on the title bar section (non-client area) if you want, by simply adding controls through a simple property in the component.

 

 

2.  Advanced option: Custom draw the Window Chrome on your own

 

The component also exposes an interface IModernWindowChromeProvider which you can implement to provide your own custom drawing of the chrome - i.e. the Border and the title bar contents - all by your own code, without worrying about handling the nuances of the complex Win32 non-client area messages.

In fact, when using this interface, you would not even know that you are actually responding to the window's non-client area Win32 messages.

 

This custom interface also provides some special methods that will be called when some specific non-client Windows messages are executed, so you can add any custom code that you want executed at that time.

 

Component Features In Detail

 

 

 

1. Simple to use

 

Simply derive from the ModernChromeWindow class instead of the standard .NET Form class, and you are ready to go

This will render the default customization pre-defined in the component - i.e. one of the built-in themes, viz., Office Black.

 

Of course, you can always set up your own advanced customization on top of what comes built-in.

 

Since the component derives from Form class and keeps all of its standard behavior and provides additional behaviors on top (i.e. Sizing, Moving, etc.) the change to your code is only a one Word change - i.e replace Form with ModernChromeWindow class.

 

 

 

 

 

 

2. Full Visual Studio design-time support

 

The component supports the Visual studio IDE design-time, so that it displays the non-client area (rendering and its behavior) as-is in the designer view.

So, as you customize the property values of the component when in design time mode, you will see it appear in the view, so you can experience the full WYSIWYG feature.

 

 

 

 

 

3. True non-client area drawing

 

The component draws into the real non-client area by making the appropriate calls into the Operating system to inform it of the intended non-client area that the system should honor as non-client area.

In other words,  it does not simply fake by drawing something that looks like a non-client area in your Form client area, but rather actually provides you a real non-client area.

 

The component paints the real non-client area, by doing all the heavy-lifting of managing and responding to all relevant non-client area Win32 messages, and lets you simply set properties to help draw the chrome as you like.

 

In fact, if you use the advanced feature of custom implementing our IModernWindowChromeProvider interface, you will be able to completely custom paint the non-client area yourself (with as much ease as if you were painting the client area), and be able to respond to mouse messages / activities as well.

 

 

 

4. Works in all mainstream Windows Operating systems: No dependency on OS theme specific libraries such as uxtheme.dll, etc.

 

The component is completely custom written in order to provide (out-of-the-box) customizable drawing of the non-client areas, and hence there is no direct dependency on any OS theme specific libraries such as uxtheme.dll.

This means that you can use this library to present cool window forms applications with heavily customized non-client areas as you wish, across any Windows Operating system, including Windows XP, Vista, Windows 2003, Windows 2008, Windows 7 and Windows 8.

 

 

 

5. No complex style editors or skinning involved

 

The customization provided by the component does not involve any kind of complex styling or skinning (or skin files) to be created.

 

All you need to do is either use the built-in drawing themes (like MS Office, WinRT, etc.) or provide your own values for the customization, just simply by setting simple properties of the component in code or at design-time (via properties editor), just like the way you are normally used to with other standard .NET controls.

 

 

 

 

 

 

 

6. Sizing and moving behavior supported

 

Although the component by default makes the FormWindowState to Borderless window (thereby removing the standard Moving & Sizing behaviors provided by WinForms .NET Form class), the component provides its own custom implementation for sizing and moving the form window.

 

 

 

7. Out-of-the-box support for ready-to-use Window rendering themes

 

The component provides out-of-the box the following styled Window chrome rendering themes ready to use:

 

  • VisualStudio - Light
  • VisualStudio - Dark
  • Office Blue
  • Office Black
  • Office Silver
  • Win 8 Native
  • WinRT (a.k.a. Metro)
  • CadetBlue
  • SandyBrown
  • SeaGreen
  • Salmon
  • Gradient CadetBlue
  • Gradient SandyBrown
  • Gradient SeaGreen
  • Gradient Salmon

 

 

 

 

 

 

 

 

8. Custom Theme supported

 

Also available in the component, is a theme named “Custom”, that lets you customize many aspects of the application window chrome rendering and create your own theme for your application, just by simply setting up some CLR properties.

 

 

 

 

9. Hosting .NET controls on the title bar section

 

The component exposes a simple property that allows you to add  any .NET control (standard .NET or even custom .NET controls) to be hosted on the non-client area / title bar area.

 

You can even specify exactly where in the title bar (in client co-ordinates) that the child control(s) should be rendered.

Your user can interact with these controls (on the title bar) as though they were hosted on the client area of the form.

 

 

A screen-shot of the ModernChromeWindow form instance in action, where its title bar (non-client area) is set up to host some .NET controls on it

 

 

 

 

 

 

10. Supports plugging-in your own custom chrome drawing and behavior provider

 

In addition to the very rich feature of being able to host custom .NET controls on the non-client area (title bar section) as detailed in the point above, the control also lets you to completely draw the window's chrome all by yourself.

 

Note that you need not use this advanced feature if you simply looking to host some .NET controls on the title bar, since in that scenario you can simply set up those controls through a simple CLR style property on the component.

But if you wanted to take control of painting the full window's chrome by yourself, you could do so by using an additional rich mechanism as detailed below.

 

The component exposes an interface IModernWindowChromeProvider which you can implement to provide your own custom drawing of the chrome - i.e. the Border and the title bar contents - all by your own code, without worrying about handling the nuances of the complex Win32 non-client area messages.

 

 

A sample custom window drawn by implementing the interface IModernWindowChromeProvider, and being able to draw custom controls on the non-client area of the window:

 

 

 

 

 

 

 

 

11. Supports transparent background rendering of non-client areas

 

By setting up some simple Boolean properties, you can specify whether to draw the non-client area i.e. the title bar and / or the border, with their background drawn as transparent.

 

You can choose to either draw transparently the title bar only or even both title bar and the border.

The component also provides an additional property whereby you can set up the title bar text foreground brush so that the component can use it to draw the title text with that brush, specifically when you have asked it to draw the title bar background as transparent.

 

 

 

12. Customizable border rendering

 

This feature allows you to customize:

 

  • Border thickness
  • Border color

 

 

 

 

 

 

13. Customize the Application Chrome Title bar height

 

With this feature, you can set the Non-client area / title bar section to any height that you desire - i.e. to a more larger or smaller than the standard 32-pixels unit height of Title bar area by simply setting the title bar height property.

 

 

 

 

 

 

 

14. Customize the Application Chrome Title bar background brush

 

With this feature, using some simple properties, you can set the brush (i.e. solid, linear gradient, texture, image brush etc.), brush color, and the gradient mode (if need be), to draw the title bar section of the non-client area of the window.

Note that, by default the title bar and the border of the chrome are drawn using the same color. But if you need, you could set two separate colors, one for drawing the window border and the other one for drawing the title bar background.

 

 

 

15. Render custom sized Application Icon 

 

By setting a property, you can host a larger sized icon if your application has such a need. You could think of using this feature by increasing the Title bar area of the non-client area height, and could have a need to draw a larger sized Application icon at the left hand corner of the non-client area chrome.

 

Aside this, you can also set a property to specify whether the app icon should be drawn or not. This could be useful to change the visibility of the icon at run-time.

 

 

 

 

 

 

16. Customize the application chrome command buttons for:

 

  • Background/Fill color
  • Border color
  • Foreground color - i.e. the color to use for drawing the internal drawings such as the minimize, maximize, restore and the Close box image inside the command buttons
  • Background colors for various visual states – i.e. different colors can be set for different states such as Normal, Hot, Pressed and Disabled
  • Button sizes: You could setup a custom size - be it larger or smaller, for the command buttons drawing.

 

 

Different colors customizations for the command buttons

 

 

 

 

Different size customizations for the command buttons

 

 

 

 

 

 

17. Customize Window Chrome command buttons images

 

A couple of options are available with this feature: Either you can...

 

  • Use the default button painting and also have the ability to customize the colors for drawing it, Or
  • Supply your own custom images for drawing the buttons (including support for setting up different button images for different visual states of the button such as Normal, Hot, Pressed, and Disabled)

 

 

 

 

 

 

18. Customize Window Chrome command buttons location in the chrome

 

By setting a simple margin property, you can set the location of where the command buttons will appear in the chrome.

 

 

 

 

 

 

19. Customize Window Chrome command buttons visibility / availability

 

By setting a simple property, you can switch off the visibility of the Minimize, maximize / restore and Close buttons completely.

For example, in one scenario, you could simply switch off displaying the minimize and maximize/restore buttons and show only the Close command button, or switch off all of these buttons visibility completely.

 

 

 

 

 

 

 

20. Provides system commands context menu, and support for custom Context menu

 

The component provides built-in mechanism to display system menu when your users right-click on the title bar area or the Application’s Task bar button (Right-click in earlier windows, and Shift + Right-click in Window Vista upwards)

You can also set up your custom context menu instance and supply that as the one that the control should display when the user right-clicks on the title bar or the app’s task bar button.

 

 

 

 

 

 

 

 

 

 

 

21. Window edges / corners customization

 

The component allows you to specify how the window’s edges should be drawn – i.e. with curved edges or sharp rectangular corners. This can be done by setting a custom value to the curve edge radius value exposing property of the class.

 

 

 

22. Supports (optionally) rendering as a chrome-less window, but keeping it sizable

 

The component also supports rendering the Form window instance without its chrome - i.e. it will draw its border (with a customized border size if need be), but with no title bar and no window command buttons on it and no way to move the window, but allowing the window to be re-sized.

 

 

 

23. Custom implementation for enabling Windows + <key> hot keys

 

 

The control features automatic / built-in support for many of Windows + Hot key(s) global hook.

 

Hot keys automatically supported

 

The control has built-in support for many of the “Windows” hot keys (global) viz.,

 

  • Windows + <Up> [Maximize]
  • Windows + <Down> [Minimize]

 

  • Desktop docking:
    • Windows + <Left>
    • Windows + <Right>

 

  • Windows + Home (Minimize all process windows excluding current window)
  • Windows + <P>: Screen / Projection setup service invocation from the Operating system

 

 

Automatic “attaching” and “detaching” of Global hot keys

 

The implementations automatically detects the window’s active/non-active status accordingly attaches and detaches to the internal global hook with the Operating system, so that when the window is not active, the hooks are not currently in force and hence the user can use it normally with other processes or the window OS itself.

 

 

Advanced docking features with Windows Desktop

 

When performing the Window docking in the desktop, the control will perform advanced calculations to support automatic cycling and docking scenarios, viz.,

 

  • If the window is already docked to the left, a Window + <Left> will move it the right half of the screen
  • If it is already docked to the right side of the desktop, a Window + <Left> will make the window restored to its original size
  • If the window is already docked to the right side of the desktop, a Window + <Right> will move it to the left half of the desktop screen
  • If the window is already docked to the left side of the desktop, a Window + <Right> will resize the window its original size (restore size)

 

 

Multi-monitor support

 

The control has custom implementation for keyboard based multi-monitor window movements & sizing for handling the following keys:

 

  • Windows + Shift + Left
  • Windows + Shift + Right

 

The control will automatically detect available attached monitors, and move the window between them.

 

 

Automatic Cycling while keys are kept pressed

 

If the users keep the hot keys pressed, the control will automatically cycle the window movements for all of the supported Windows + * hot keys

 

 

“Desktop peek” feature supported

 

In addition to the above hot keys, this control also has support for automatically performing Aero “Desktop peek” (Windows + <Spacebar> in Win 7, or Windows + <comma> in Windows 8.0 / 8.1) when the control is used in OS versions Windows 7 and upwards.

 

 

Ease of enabling the Windows Global Hooks feature

 

The way you enable the window to have the new Windows hot key features is via a simple bool property ShouldEnableWindowsKeyHooks.

Depending on this property value setting, the control will automatically do all the heavy-lifting to deliver the features.

 

 

 

24. Setup gap between chrome window command buttons

 

You can ask the control to setup gap between chrome window command buttons - i.e. a deterministic gap between the Minimize, Maximize / restore and Close buttons on the title bar area

 

 

     

 

 

 

25. Specify a custom text alignment for your window title-bar text

 

You can set up a custom chosen text alignment for the window title-bar text as you desire, say for example: Left, Center or Right, by setting a simple property.

This property also allows setting up a custom string-format settings (text trimming, format-flags, etc.) of your choice to use, when formatting the text for the title-bar.

26. Many more features supported, including, being able to...

 

  • Specify whether the Window instance should cover (and draw over) the task bar window area as well, when its WindowState is currently Maximized or should it not cover the task bar area.
  • Specify whether to draw the window border when in maximized mode too

 

  • A property IsWindowLocked is available, which will determine whether the user can or cannot move the window at runtime

 

  • Event WindowRestoreOrMaximizeRequested that is raised before the WindowState is changed - i.e. when the user has requested the window's state to be changed to either Maximize or Restore, and the state is yet to be changed as yet.
  • Event WindowMinimizeRequested is just raised before the window's state is about to be set to Minimized.
  • Event WindowStateChanged is raised after the window state has been changed.

 

    • The above events come in handy when you want to do something before the window has actually changed its WindowState
    • They cater to all situations where the state change could arise from -i.e. Double-click on the window title bar, Clicking on the Max/Restore buttons on the titlebar or using the keyboard keys or using the System commands on the window.
    • Also, when the window's visual state is about to be changed (i.e. Minimize, Maximize and Restore), the above mentioned special events also provide additional information via the event arguments, including information on what was the previous visual state and what is the currently changed one.

 

  • Some more useful events are raised so as to let you handle it if need be., viz:
    • WindowChromeTitlebarHeightChanged
    • WindowChromeBorderSizeChanged
    • WindowCloseRequested
    • WindowIconClicked

 

  • More customization features included, including properties to configure:
    • whether the control should enable the feature of automatically responding to either minimize or restore (as the case may be) upon the user clicking on the Window's taskbar icon
    • whether the control performs Windows Aero style "animation" while the window is being minimized or restored