form.Text = string.Empty;
form.ControlBox = false;
form.FormBorderStyle = FormBorderStyle.SizableToolWindow;
For a fixed size window, you should still use FormBorderStyle.SizableToolWindow
, but you can override the form's WndProc
to ignore non-client hit tests (which are used to switch to the sizing cursors):
protected override void WndProc(ref Message message)
{
const int WM_NCHITTEST = 0x0084;
if (message.Msg == WM_NCHITTEST)
return;
base.WndProc(ref message);
}
If you want to really enforce the size, you could also set MinimumSize
equal to MaximumSize
on the form.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…