今天试了试,好像没有什么变化啊,大化小化关闭是不是这样:
namespace Winform大化小化关闭
{
public partial class Form1 : Form
{
[DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)]
public static extern int GetWindowLong(HandleRef hWnd, int nIndex);
[DllImport("user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)]
public static extern IntPtr SetWindowLong(HandleRef hWnd, int nIndex, int dwNewLong);
public Form1()
{
InitializeComponent();
}
protected override CreateParams CreateParams
{
get
{
const int WS_MINIMIZEBOX = 0x00020000; // Winuser.h中定义
CreateParams cp = base.CreateParams;
cp.Style = cp.Style | WS_MINIMIZEBOX; // 允许最小化操作
return cp;
}
}
private void Form1_Load(object sender, EventArgs e)
{
//无标题窗体右键菜单
int WS_SYSMENU = 0x00080000; // 系统菜单
int WS_MINIMIZEBOX = 0x20000; // 最大最小化按钮
int windowLong = (GetWindowLong(new HandleRef(this, this.Handle), -16));
SetWindowLong(new HandleRef(this, this.Handle), -16, windowLong | WS_SYSMENU | WS_MINIMIZEBOX);
}
}
} |