I am looking to draw my non-client area in C#, for example, instead a rectangle as a form, i want an ellipse (this is an example), but how can i do it?
I basically w
You have to set the window xaml file like this
<Window x:Class="[YourwindowClass]"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="..."
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent">
[Draw the window]
</Windows>
You will need to generate your own click handlers for dragging the window though. There are some examples here and here.
m0sa has provided a WPF answer already.
For WinForms, you'll need to process the WM_NCPAINT
message (override Control.WndProc
) and also enable the layered window style in order to have transparent regions in the bounding box.
If you are talking Winforms, and want to draw in the Non Client area, Ben's suggestion will work.
If you want your window a different shape - say Round like a clock, then you will be looking at Regions.
GraphicsPath path = new GraphicsPath();
path.AddEllipse(100, 100, 100, 100);
this.Region = new Region(path);