C#对WinForm窗口按钮禁用
[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窗体加载的代码中定义以下代码(其他按钮的禁用可以参照上面代码所定义的变量):
inthMenu;hMenu = GetSystemMenu(this.Handle.ToInt32(), 0);
RemoveMenu(hMenu, SC_CLOSE, MF_REMOVE);
以上是 C#对WinForm窗口按钮禁用 的全部内容, 来源链接: utcz.com/z/512975.html