With form1, when i hold bottom-left to resize, it's is limit at MinumumSize(300, 300). But although set MinimumSize = new Size(50, 50), Width and Height of MyControl still can less than 50. Do you know how to make MyControl like Form? Thank in advance!
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
FormBorderStyle = FormBorderStyle.None;
MinimumSize = new Size(300, 300);
}
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x84) //WM_NCHITTEST
{
Point pos = new Point(m.LParam.ToInt32());
pos = this.PointToClient(pos);
if (pos.X >= this.ClientSize.Width - 6 && pos.Y >= this.ClientSize.Height - 6)
{
m.Result = (IntPtr)17;
return;
}
}
base.WndProc(ref m);
}
}
public class MyControl : Control
{
public MyControl()
{
MinimumSize = new Size(50, 50);
}
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x84) //WM_NCHITTEST
{
Point pos = new Point(m.LParam.ToInt32());
pos = this.PointToClient(pos);
if (pos.X >= this.ClientSize.Width - 6 && pos.Y >= this.ClientSize.Height - 6)
{
m.Result = (IntPtr)17;
return;
}
return;
}
base.WndProc(ref m);
}
}