برای ساخت فرمهای دورگرد می توانید از کد زیر استفاده کنید
هر چه اعداد 200 در ردیف آخر کد را افزایش دهید دور فرم گردتر و هرپه این دو عدد را کوچکتر کنید فرم به شکل مربع نزدیکتر می گردد
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsRound
{
public partial class Form1 : Form
{
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn
(
int nLeftRect,
int nTopRect,
int nRightRect,
int nBottomRect,
int nWidthEllipse,
int nHeightEllipse
);
public Form1()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
this.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 200, 200));
}
//----------------------------------------------
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
پنجشنبه 13 تیر 1398 ساعت 00:51