我想创建一个新表单,设置为最大化。它应该显示标题栏和任务栏。到目前为止,这不是一个大问题。当我设置this.MaximizeBox = false;
时,标题栏上的按钮被禁用但如果我拖动或双击标题栏,则表单进入窗口模式(在Windows 7上测试)。
将MinimumSize
和MaximumSize
设置为相同的值不成功。
答案 0 :(得分:1)
public class Form1 {
public Form1(){
InitializeComponent();
WindowState = FormWindowState.Maximized;
Load += (s,e) => {
MaximizeBox = false;
};
}
bool hitControlButtons;
protected override void WndProc(ref Message m)
{
if ((!hitControlButtons) && (m.Msg == 0xa3 || m.Msg == 0xa1))//WM_NCLBUTTONDBLCLK and WM_NCLBUTTONDOWN
{
return;
}
if (m.Msg == 0xA0)//WM_NCMOUSEMOVE
{
int wp = m.WParam.ToInt32();
hitControlButtons = wp == 8 || wp == 20 || wp == 9;//Mouse over MinButton, CloseButton, MaxButton
}
base.WndProc(ref m);
}
}