//定义
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);

解决方案 »

  1.   

    >>>Form2生成Form3,Form3生成Form4,……在关闭最后一个窗口时同时关闭从Form3开始的窗口。
      这样的话,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);
    }
      

  2.   

    像window开始菜单那样。可以做个stack,一级级的将打开的子窗口入,当一个收的时候,判断有无子窗体,有则全收