lovegis

导航

屏蔽窗体关闭按钮

[DllImport("USER32.DLL")]
  private static extern IntPtr GetSystemMenu(IntPtr hWnd, UInt32 bRevert);
  [DllImport("USER32.DLL")]
  private static extern UInt32 RemoveMenu(IntPtr hMenu, UInt32 nPosition, UInt32 wFlags);

  private const UInt32 SC_CLOSE = 0x0000F060;
  private const UInt32 MF_BYCOMMAND = 0x00000000;

  public Form1()
  {   
   InitializeComponent();

   IntPtr hMenu = GetSystemMenu(this.Handle, 0);
   RemoveMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
   }

posted on 2009-08-11 10:21  lovegis  阅读(337)  评论(0编辑  收藏  举报