1.在FORM窗体代码中定义如下代码:this
[DllImport("USER32.DLL")] publicstaticexternintGetSystemMenu(inthwnd,intbRevert); [DllImport("USER32.DLL")] publicstaticexternintRemoveMenu(inthMenu,intnPosition,intwFlags); constintMF_REMOVE = 0x1000; constintSC_RESTORE = 0xF120; constintSC_MOVE = 0xF010; constintSC_SIZE = 0xF000; constintSC_MINIMIZE = 0xF020; constintSC_MAXIMIZE = 0xF030; constintSC_CLOSE = 0xF060;
2.假设要禁用“关闭”按钮,则须要在FORM窗体加载的代码中定义如下代码(其余按钮的禁用能够参照上面代码所定义的变量):code
inthMenu; hMenu = GetSystemMenu(this.Handle.ToInt32(), 0); RemoveMenu(hMenu, SC_CLOSE, MF_REMOVE);