Hi, this is pretty simple, you need to use the form's MouseMove, MouseUp, and MouseDown events to create your own resize logic.
Example:
Code:
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private bool resizing = false;
private Point last = new Point(0, 0);
public Form1()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (!resizing) // handle cursor type
{
bool resize_x = e.X > (this.Width - 8);
bool resize_y = e.Y > (this.Height - 8);
if (resize_x && resize_y)
this.Cursor = Cursors.SizeNWSE;
else if (resize_x)
this.Cursor = Cursors.SizeWE;
else if (resize_y)
this.Cursor = Cursors.SizeNS;
else this.Cursor = Cursors.Default;
}
else // handle resize
{
int w = this.Size.Width;
int h = this.Size.Height;
if (this.Cursor.Equals(Cursors.SizeNWSE))
this.Size = new Size(w + (e.Location.X - this.last.X), h + (e.Location.Y - this.last.Y));
else if (this.Cursor.Equals(Cursors.SizeWE))
this.Size = new Size(w + (e.Location.X - this.last.X), h);
else if (this.Cursor.Equals(Cursors.SizeNS))
this.Size = new Size(w, h + (e.Location.Y - this.last.Y));
this.last = e.Location;
}
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
this.resizing = true;
this.last = e.Location;
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
this.resizing = false;
}
}
}
This principle could also be used to make your form movable.