Move a borderless form.

  • VB Code
  • C# Code

These two examples show how to move the form from either the Forms or a controls MouseDown event.


An example of a moveable/resizable shaped form.

This is by no means a complete solution, just an idea for creating custom shaped forms with custom Titlebars.
The form can be dragged by its fake titlebar, and if right clicked the fake Titlebar will popup the WindowMenu.
The CreateParams property has been modified to add a System Menu (with Min,Move and Close items) to a borderless form.
The Titlebar button are not controls, they are simply drawn in the fake title bar and they react to hittesting.
The MainMenu is actually labels that popup Contextmenus.
The form can be resized only by its resizegrip, but you could define regions for each of the sides and corners and allow sizing by dragging the edge. The example requires a little work to be useable, but it should give you an idea of how to achieve this solution.
With a little InterOp you can draw a standard TitleBar onto which you can place custom buttons, and this solution is much simpler than that of OwnerDrawing the NonClient Area to achieve the same effect.

  • VB Code
  • C# Code

Customise an MDI application.

The following code modifies the MDI Client of a form.
There is a custom Background, and the border has been flattened since the default 3D appearance looks poor when you wish to use Splitter controls to adjust the MDI client size.

  • VB Code
  • C# Code

Use a TabControl for MDI navigation.

  • VB Code
  • C# Code

Add forms as usercontrols.

The following class is a modified form that can be treated as a usercontrol. The image above shows a Panel with a contained form that itself has a contained form.
Adding forms is simple enough, but getting them to appear active is a little trickier. This class has been decorated with the ToolBoxItemAttribute so that you may add the form to your toolbox for ease of use at design time.
The class includes the moveable property shown in Herfied K. Wagners Windows Forms section

  • VB Code
  • C# Code

Creating Forms with Custom Appearance, but standard Behaviour (option 1).

There are several ways to Custom Paint a form, but each has their flaw.
This method starts with a standard Form that has its BorderStyle set to None.
We also create a WindowMenu class which pops up in place of the standard WindowMenu. We do this because restoring the standard WindowMenu causes the standard Window Size options to be lost and these cannot be restored without adding the sizable border which we do not want to see.
To get the standard Size and Move options we simply create GraphicsPaths that react to the muse in the same way as the standard Non-Client form parts do. To achieve this we simply intercept and manipulate a few standard Windows messages. For this article I have not used any Interop calls, but you may get more flexible results by using SendMessage() and SetMenuItemBitmaps() rather than sending WndProc() calls and OwnerDrawing the custom WindowMenu.
The example here simply paints the defined paths in order that you can physically see how this method works, it is not meant to be pretty. You are not restricted to where the paths are placed or what shape they are, you dont even have to stick to them exactly when painting, the paths are simply there for mouse interaction.
The only real problem with this method is that if you set AutoScroll to true then Scrollbars will appear on top of the fake NonClientArea. A simple fix for this is to dock a Panel to the form (set the forms margins as appropiate) and use this as the Form Client.

  • VB Code
  • C# Code