实现方法如下:
1.引用命名空间
using System.Runtime.InteropServices;
2.声明如下变量:
public class Form1 : System.Windows.Forms.Form
{
//.....
[DllImport("user32.dll",EntryPoint="GetSystemMenu")]
extern static IntPtr GetSystemMenu(IntPtr hWnd, IntPtr bRevert);
[DllImport("user32.dll",EntryPoint="RemoveMenu")]
extern static int RemoveMenu(IntPtr hMenu, int nPos, int flags);
//.....
}
3.在Form的构造函数里加入代码
public Form1()
{
const int MF_BYPOSITION = 0x0400;
const int MF_REMOVE = 0x1000;
FormBorderStyle = FormBorderStyle.FixedSingle;
MaximizeBox = false;
MinimizeBox = false;
RemoveMenu(GetSystemMenu(Handle,IntPtr.Zero),1,MF_BYPOSITION |MF_REMOVE);
}
就OK啦