If you needed full, Form-level functionality, one way you could solve this would be to make a Form with FormBorderStyle = None. This would remove the entire border from the form, and it'll just appear as a flat rectangle with whatever background color you'd put on there.
There are a couple issues with this:
- The user won't be able to move it, unless you implement some sort of click handler to allow dragging it around the screen.
- The user will have to use the task bar (assuming you've left it visible there) or Alt-F4 to close the window.
Based on your question about how to solve #2, there's an SO page on How to drag a borderless Windows Form by mouse. In case it gets deleted anytime soon, I'll reproduce Joey's code (based on a linked article):
// DllImportAttribute requires reference to System.Runtime.InteropServices
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
public Form1()
{
InitializeComponent();
}
private void Form1_MouseDown_1(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
}
Note that I haven't done anything to test this other than just pasting it in and verifying that, yes, you can drag your Form with the mouse within its content area. Note also that this drag action will only work on empty areas of the Form - you won't be able to drag it if your mouse is over one of the Form's controls.
Edit: The title of the question was changed since it was originally posted - originally, the question was not substantially dedicated to how to create a non-rectangular form and more about how to create a borderless form - but the non-rectangular borders portion of the question as it stands now is solved by Olivier Jacot-Descombes below. I won't steal his contribution, but a combination of these two answers should give you exactly what you want.