You can resize the form using the Wndproc method. Run a test using the code below:
public partial class Form1 :Form
{
public Form1()
{
InitializeComponent();
}
private int borderWidth = 5; //Exemplo apenas para teste
private new Padding Padding = new Padding(50); //Exemplo apenas para teste (Pode ser especificado direto nas propriedades do Form)
private WinApi.HitTest HitTestNCA(IntPtr lparam)
{
Point vPoint = new Point((Int16)lparam, (Int16)((int)lparam >> 16));
int vPadding = Math.Max(Padding.Right, Padding.Bottom);
if (RectangleToScreen(new Rectangle(ClientRectangle.Width - vPadding, ClientRectangle.Height - vPadding, vPadding, vPadding)).Contains(vPoint))
return WinApi.HitTest.HTBOTTOMRIGHT;
if (RectangleToScreen(new Rectangle(borderWidth, borderWidth, ClientRectangle.Width - 2 * borderWidth, 50)).Contains(vPoint))
return WinApi.HitTest.HTCAPTION;
return WinApi.HitTest.HTCLIENT;
}
protected override void WndProc(ref Message m)
{
if (DesignMode)
{
base.WndProc(ref m);
return;
}
switch (m.Msg)
{
case (int) WinApi.Messages.WM_NCHITTEST:
WinApi.HitTest ht = HitTestNCA(m.LParam);
if (ht != WinApi.HitTest.HTCLIENT)
{
m.Result = (IntPtr) ht;
return;
}
break;
}
base.WndProc(ref m);
}
[SuppressUnmanagedCodeSecurity]
internal static class WinApi
{
public enum Messages : uint
{
WM_NCHITTEST = 0x84,
}
public enum HitTest
{
HTCLIENT = 1,
HTBOTTOMRIGHT = 17,
HTCAPTION = 2
}
}
}
*Note that the Padding property will determine the area in which the resize may occur, in this case, a square area of 50 pixels in the lower right corner.
This code snippet was taken from a framework designed to create Metro-style applications using Windows Forms:
Metroframework - Modern UI for Winforms (http://thielj.github.io/MetroFramework/)
If the Forms and the controls they provide do not meet your requirements, you can get the source code and make the necessary changes.
You’ll need to develop this...
– Jéf Bueno
Do you have any idea where I can start?
– Joaquim Caetano Teixeira