110,533
社区成员
发帖
与我相关
我的任务
分享
private const int WS_MINIMIZEBOX = 0x20000;
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
if (!base.DesignMode)
{
cp.Style |= WS_MINIMIZEBOX;
}
return cp;
}
}
另一种方法
Win32单元
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SetWindowLong(IntPtr hWnd, int Index, int Value);
public const int WS_SYSMENU = 0x80000;
public const int WS_SIZEBOX = 0x40000;
public const int WS_MAXIMIZEBOX = 0x10000;
public const int WS_MINIMIZEBOX = 0x20000;
public const int SM_CXFRAME = 0x20;
public const int WS_THICKFRAME = 0x40000;
private void SetFormStyle(Form form)
{
int i = Win32.GetSystemMetrics(Win32.SM_CXFRAME);
this.FormBorderStyle = FormBorderStyle.None;
int windowLong = (Win32.GetWindowLong(form.Handle, -16));
OperatingSystem osinfo = Environment.OSVersion;
if (osinfo.Platform == PlatformID.Win32NT)
{
if (osinfo.Version.Major == 6)
{
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width + i, Screen.PrimaryScreen.WorkingArea.Height);
Win32.SetWindowLong(form.Handle, -16, windowLong | Win32.WS_MAXIMIZEBOX | Win32.WS_MINIMIZEBOX);
}
else
{
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width + i, Screen.PrimaryScreen.WorkingArea.Height + i);
Win32.SetWindowLong(form.Handle, -16, windowLong | Win32.WS_SYSMENU | Win32.WS_THICKFRAME | Win32.WS_MAXIMIZEBOX | Win32.WS_MINIMIZEBOX);
}
}
}