日期:2014-05-17 浏览次数:21106 次
Form2 f2 = new Form2();
f2.ControlBox = false;
f2.Show();
------解决方案--------------------
如果仅仅是关闭按钮变为灰色不可用,那么如下操作
[DllImport("USER32.DLL")]
public static extern int GetSystemMenu(int hwnd, int bRevert);
[DllImport("USER32.DLL")]
public static extern int RemoveMenu(int hMenu, int nPosition, int wFlags);
const int MF_REMOVE = 0x1000;
const int SC_RESTORE = 0xF120; //还原
const int SC_MOVE = 0xF010; //移动
const int SC_SIZE = 0xF000; //大小
const int SC_MINIMIZE = 0xF020; //最小化
const int SC_MAXIMIZE = 0xF030; //最大化
const int SC_CLOSE = 0xF060; //关闭
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
int hMenu = GetSystemMenu(f2.Handle.ToInt32(), 0);
RemoveMenu(hMenu, SC_CLOSE, MF_REMOVE);
f2.Show();
}
------解决方案--------------------
参考链接
------解决方案--------------------
将form2的FormBorderStyle设为none看,是不是你想要的