Here's one solution that results in no Form Border, and renders the Form re-sizable:
1. set 'FormBorderStyle to 'FixedToolWindow, and hide the other usual stuff.
2. this example does not include code for moving the Form; that's left for you to write.
using System;
using System.Drawing;
using System.Windows.Forms;
namespace YourNameSpace
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
const int MoveZoneSize = 16;
const int ReSizeThreshold = 4;
private Rectangle scrnBounds;
private Rectangle moveZone;
private int mdx, mdy, dx, dy;
private bool mouseIsUp = true;
private void Form1_Load(object sender, EventArgs e)
{
UpdateScreenSize();
}
private void UpdateScreenSize()
{
moveZone = new Rectangle(0,0,MoveZoneSize,MoveZoneSize);
scrnBounds = this.DisplayRectangle;
moveZone.Offset(scrnBounds.Right - MoveZoneSize, scrnBounds.Bottom - MoveZoneSize);
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (ModifierKeys == Keys.Alt && e.KeyCode == Keys.Escape)
{
this.MouseMove -= Form1_MouseMove;
this.Close();
}
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (moveZone.Contains(e.Location))
{
mdx = e.X;
mdy = e.Y;
this.MouseMove += Form1_MouseMove;
}
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
this.MouseMove -= Form1_MouseMove;
UpdateScreenSize();
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
dx = Math.Abs(e.X - mdx);
dy = Math.Abs(e.Y - mdy);
if (dx < ReSizeThreshold && dy < ReSizeThreshold) return;
this.Width = e.X;
this.Height = e.Y;
}
}
}
Notes:
1. a Rectangle (square) 'moveZone is created that encloses an area of the bottom-right of the Form of size 'MoveZoneSize.
2. a threshold for "dampening" mouse move events 'ReSizeThreshold is defined. this may make the resizing of the Form visually smoother.
3. mouse down is detected and if the mouse down location is in the 'moveZone bounds, the mouse move handler is wired up to the Form.
4. in the mouse move event, the delta of mouse movement is calculated, and if it's smaller than 'ReSizeThreshold the method exits. if the delta is larger, then the Form is resized, and the current bounds of the form and the bounds of the 'moveZone rectangle are re-calculated.
Other comments:
1. depending on computer, graphics card, memory, etc., and the possible complexity of Form elements and their use of Anchor and Dock, Padding, Margin, etc. Properties: the visual quality the Form resize by mouse at run-time ... may vary. Of course, you should set the Form's 'DoubleBuffered Property to 'true.