So, I don't think you can get the right-click menu item to look exactly the same. The main reason is that I can't see a way to draw the contextMenuStrip below the top of the taskbar. But, what you can do is create your own ContextMenuStrip with the items you want. Then, you override the WndProc method and show the ContextMenuStrip. It looks like:
private const int WMTaskbarRClick = 0x0313;
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WMTaskbarRClick:
contextMenuStrip1.Show(Cursor.Position);
break;
default:
base.WndProc(ref m);
break;
}
}
Resizing the form is a bit trickier. You have to first decide on a region that you will be using to allow the resize. Once you've done that, you need to hook the mouse move and see if the cursor is in that region. If it is, then you change the cursor. Then, if the user mouses down while the cursor is changed, you start dragging.
It's easy for a rectangular form. I've done the following:
private bool dragging = false;
private Point offset;
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (!dragging)
{
if (e.X < this.Width && e.X > this.Width - 10
&& e.Y < this.Height && e.Y > this.Height - 10)
{
offset = new Point(this.Width - e.X, this.Height - e.Y);
this.Cursor = Cursors.SizeNWSE;
}
else
{
this.Cursor = Cursors.Default;
}
}
else
{
this.Width = e.X + offset.X;
this.Height = e.Y + offset.Y;
}
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (this.Cursor == Cursors.SizeNWSE)
dragging = true;
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
if (this.Cursor == Cursors.SizeNWSE)
dragging = false;
}
I've basically defined a region to the bottom right where the user can mouse over and then resize it.