using System.Runtime.InteropServices;[DllImport("User32.dll")] public static extern int GetSystemMenu(int hWnd, int bRevert);[DllImport("User32.dll")] public static extern int RemoveMenu(int hMenu, int nPosition, int wFlags);private void yourform_Load(object sender, System.EventArgs e) { int lSysMenu; const int MF_BYPOSITION = 1024; lSysMenu = GetSystemMenu(this.Handle.ToInt32(), 0); RemoveMenu(lSysMenu, 6, MF_BYPOSITION); }
public static extern int GetSystemMenu(int hWnd, int bRevert);[DllImport("User32.dll")]
public static extern int RemoveMenu(int hMenu, int nPosition, int wFlags);private void yourform_Load(object sender, System.EventArgs e)
{
int lSysMenu;
const int MF_BYPOSITION = 1024;
lSysMenu = GetSystemMenu(this.Handle.ToInt32(), 0);
RemoveMenu(lSysMenu, 6, MF_BYPOSITION);
}
ControlBox = false;禁用:
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
}
good lucky
那窗口的标题栏都没有了!
{
e.Cancel = true;
}
是不是禁止form关闭?
[DllImport("User32.dll")]
public static extern IntPtr GetSystemMenu(int hWnd, int bRevert);
[DllImport("User32.dll")]
public static extern int RemoveMenu(int hMenu, int nPosition, int wFlags);
const int MF_REMOVE = 0x1000;
const int SC_RESTORE = 0xF120; //还原
const int SC_MOVE = 0xF010; //移动
const int SC_SIZE = 0xF000; //大小
const int SC_MINIMIZE = 0xF020; //最小化
const int SC_MAXIMIZE = 0xF030; //最大化
const int SC_CLOSE = 0xF060; //关闭
Form_Load里 int hMenu;
hMenu = GetSystemMenu(this.Handle.ToInt32(), 0);
RemoveMenu(hMenu, SC_CLOSE, MF_REMOVE);这样搞出来的窗口的关闭是被禁用的,但还是显示出来了,
有人知道怎么能让它干脆不显示出来吗?偶也学习学习~~