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);