/// <summary> /// 设置窗体的圆角矩形 /// </summary> /// <param name="form">需要设置的窗体</param> /// <param name="rgnRadius">圆角矩形的半径</param> public static void SetFormRoundRectRgn(Form form, int rgnRadius) { int hRgn = 0; hRgn = Win32API.CreateRoundRectRgn(0, 0, form.Width + 1, form.Height + 1, rgnRadius, rgnRadius); Win32API.SetWindowRgn(form.Handle, hRgn, true); Win32API.DeleteObject(hRgn); }
/// <summary> /// 设置窗体的圆角矩形 /// </summary> /// <param name="form">需要设置的窗体</param> /// <param name="rgnRadius">圆角矩形的半径</param> public static void SetFormRoundRectRgn(Form form, int rgnRadius) { try { if (form == null) { MessageBox.Show("程序闪退调试记录"); return; } int hRgn = 0; hRgn = Win32API.CreateRoundRectRgn(0, 0, form.Width + 1, form.Height + 1, rgnRadius, rgnRadius); Win32API.SetWindowRgn(form.Handle, hRgn, true); Win32API.DeleteObject(hRgn); } catch (Exception ex) { MessageBox.Show(ex.Message, "程序闪退调试记录"); } }