You have to be careful to allow the form to resize itself at startup. Necessary to accommodate scaling needed on a machine that has a different video DPI setting or a different system font size. Or a user override that changed the height of the title bar. All of this is sorted out by the time the Load event runs. Thus:
protected override void OnLoad(EventArgs e) {
Screen scr = Screen.FromControl(this);
this.MinimumSize = new Size(this.MinimumSize.Width, this.Height);
this.MaximumSize = new Size(scr.WorkingArea.Width, this.Height);
}
The next thing you ought to do is fix the behavior of the cursor when the user moves it on an edge of the window that allows resizing the window vertically. That's a bit ugly, you have to trap the WM_NCHITTEST message with WndProc and change the message return value:
protected override void WndProc(ref Message m) {
base.WndProc(ref m);
if (m.Msg == 0x84) { // Trap WM_NCHITTEST
switch (m.Result.ToInt32()) {
case 12: m.Result = (IntPtr)2; break; // HTTOP to HTCAPTION
case 13: m.Result = (IntPtr)10; break; // etc..
case 14: m.Result = (IntPtr)11; break;
case 15: m.Result = (IntPtr)1; break;
case 16: m.Result = (IntPtr)10; break;
case 17: m.Result = (IntPtr)11; break;
}
}
}