这似乎是 netcfagl3_5.dll 中的一个错误(将通知 Microsoft)
当我们使用 pinvokes (SetWindowLong) 设置 FormBorderstyle 时,我们无法重现该问题。
如果有人遇到这种罕见的错误,这是设置 formborderstyle 而不使用 .net FormBorderStyle属性的代码。
private const uint WS_OVERLAPPED = 0x00000000;
private const uint WS_POPUP = 0x80000000;
private const uint WS_CHILD = 0x40000000;
private const uint WS_MINIMIZE = 0x20000000;
private const uint WS_VISIBLE = 0x10000000;
private const uint WS_DISABLED = 0x08000000;
private const uint WS_CLIPSIBLINGS = 0x04000000;
private const uint WS_CLIPCHILDREN = 0x02000000;
private const uint WS_MAXIMIZE = 0x01000000;
private const uint WS_CAPTION = 0x00C00000;
private const uint WS_BORDER = 0x00800000;
private const uint WS_DLGFRAME = 0x00400000;
private const uint WS_VSCROLL = 0x00200000;
private const uint WS_HSCROLL = 0x00100000;
private const uint WS_SYSMENU = 0x00080000;
private const uint WS_THICKFRAME = 0x00040000;
private const uint WS_GROUP = 0x00020000;
private const uint WS_TABSTOP = 0x00010000;
private const int WS_MINIMIZEBOX = 0x00020000;
private const int WS_MAXIMIZEBOX = 0x00010000;
private const uint WS_EX_DLGMODALFRAME = 0x00000001;
private const uint WS_EX_NOPARENTNOTIFY = 0x00000004;
private const uint WS_EX_TOPMOST = 0x00000008;
private const uint WS_EX_ACCEPTFILES = 0x00000010;
private const uint WS_EX_TRANSPARENT = 0x00000020;
private const uint WS_EX_MDICHILD = 0x00000040;
private const uint WS_EX_TOOLWINDOW = 0x00000080;
private const uint WS_EX_WINDOWEDGE = 0x00000100;
private const uint WS_EX_CLIENTEDGE = 0x00000200;
private const uint WS_EX_CONTEXTHELP = 0x00000400;
private const uint WS_EX_STATICEDGE = 0x00020000;
private const int WS_EX_NOANIMATION = 0x04000000;
public const int GWL_EX_STYLE = -20;
public const int GWL_STYLE = (-16);
public static void SetNoBorder(Form form) {
RemoveFormStyle(form, GWL_STYLE, (int)(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU));
RemoveFormStyle(form, GWL_EX_STYLE, (int)(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
}
public static void RemoveFormStyle(Form f, int modifier, int style) {
int currStyle = GetWindowLong(f.Handle, GWL_EX_STYLE);
currStyle &= ~style;
SetWindowLong(f.Handle, modifier, currStyle);
}
[DllImport("Coredll.dll", SetLastError = true)]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("coredll.dll", SetLastError = true)]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);