When resizing windows on the desktop, Windows relies on WM_GETMINMAXINFO message to obtain the size limits, so that the window will remain usable - as per Microsoft guidelines,
[Resizable windows] Should set a minimum window size if there is a size below which the content is no longer usable. For resizable controls, set minimum resizable element sizes to their smallest functional sizes, such as minimum functional column widths in list views.
By default, Windows imposes a constraint of caption bar height for height, and about 100 pixels for width (min/max/close buttons + a few letters of the name). To remove that constraint you should handle the WM_GETMAXINFO message yourself and change the minimum size to whatever is necessary.
An example of the C# code can be adapted from here:
private const long WM_GETMINMAXINFO = 0x24;
public struct POINTAPI
{
public int x;
public int y;
}
public struct MINMAXINFO
{
public POINTAPI ptReserved;
public POINTAPI ptMaxSize;
public POINTAPI ptMaxPosition;
public POINTAPI ptMinTrackSize;
public POINTAPI ptMaxTrackSize;
}
protected override void WndProc(ref System.Windows.Forms.Message m )
{
if (m.Msg == WM_GETMINMAXINFO)
{
MINMAXINFO mmi = (MINMAXINFO)m.GetLParam(typeof(MINMAXINFO));
mmi.ptMinTrackSize.x = 0;
mmi.ptMinTrackSize.y = 0;
System.Runtime.InteropServices.Marshal.StructureToPtr(mmi, m.LParam, true);
}
base.WndProc(ref m);
}
And (while researching this) I've found another SO question which deals with the same problem. Apparently you need to override WM_WINDOWPOSCHANGING
too in order for this to work in Vista and/or C#. (Another example I've seen was in Delphi, and didn't need to override the latter message as well).