//定义
public const int MF_BYCOMMAND = 0x0;[DllImport("user32.dll", EntryPoint="GetSystemMenu")]
public static extern IntPtr GetSystemMenu (
IntPtr hwnd,
int bRevert
);[DllImport("user32.dll", EntryPoint="DeleteMenu")]
public static extern int DeleteMenu (
IntPtr hMenu,
int nPosition,
int wFlags
);
//调用
IntPtr hSysMenu = GetSystemMenu(this.Handle,0);
DeleteMenu(hSysMenu,0xF060,MF_BYCOMMAND);
public const int MF_BYCOMMAND = 0x0;[DllImport("user32.dll", EntryPoint="GetSystemMenu")]
public static extern IntPtr GetSystemMenu (
IntPtr hwnd,
int bRevert
);[DllImport("user32.dll", EntryPoint="DeleteMenu")]
public static extern int DeleteMenu (
IntPtr hMenu,
int nPosition,
int wFlags
);
//调用
IntPtr hSysMenu = GetSystemMenu(this.Handle,0);
DeleteMenu(hSysMenu,0xF060,MF_BYCOMMAND);
这样的话,Form2,Form3....之间肯定得有某种联系,可能是Owner的关系
e.g
class Form2{
private void gen_Form3{
Form3 f3 = new Form3();//Form3 constructor may take some args
f3.Owner = this;
f3.Show();
}
} class Form3{
private void Form3_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
this.Owner.Close();/////for instance
}
}>>>怎么屏蔽掉窗口右上方的关闭按钮
1.
private void Form_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
}
}2.将Form的ControlBox设置为false
3.using APIusing System.Runtime.InteropServices;
[DllImport("user32.dll", EntryPoint="GetSystemMenu")]
public static extern IntPtr GetSystemMenu (
IntPtr hwnd,
int bRevert
);
[DllImport("user32.dll", EntryPoint="DeleteMenu")]
public static extern int DeleteMenu (
IntPtr hMenu,
int nPosition,
int wFlags
);
public const int MF_BYCOMMAND = 0x0;private void AboutDialog_Load(object sender, System.EventArgs e)
{
IntPtr hSysMenu = GetSystemMenu(this.Handle,0);
DeleteMenu(hSysMenu,0xF060,NativeAPI.MF_BYCOMMAND);
}