السلام عليكم ورحمة الله وبركاته ،
كيف اجعل للفورم radius في الاربع اتجهات
السلام عليكم ورحمة الله وبركاته ،
كيف اجعل للفورم radius في الاربع اتجهات
السلام عليكم ورحمة الله وبركاته ،
وجد الحل ولكن هناك مشكلة بسيطة ارجو منكم افادتي
استخدمت هذا الكود
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn
(
int nLeftRect, // x-coordinate of upper-left corner
int nTopRect, // y-coordinate of upper-left corner
int nRightRect, // x-coordinate of lower-right corner
int nBottomRect, // y-coordinate of lower-right corner
int nWidthEllipse, // height of ellipse
int nHeightEllipse // width of ellipse
);
public Form1()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 20, 20));
}
}
}ولكن لاحظت ان الـ edges غير مستوية تشعر وكأنها مشرشرة .. غير جزابة .. هل هناك حل ؟؟
private void Form1_Paint(object sender, PaintEventArgs e)
{
//Form Property
this.FormBorderStyle = FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Width = 500;
this.Height = 500;
this.BackColor = Color.CadetBlue;
this.StartPosition = FormStartPosition.CenterScreen;
//Create round Edge Using GDI+.net
//using System.Drawing.Drawing2D;
int CornerRadius = 150;
GraphicsPath gp = new GraphicsPath();
gp.AddArc(0, 0, CornerRadius, CornerRadius, 180, 90);
gp.AddArc(0 +this.Width - CornerRadius, 0, CornerRadius, CornerRadius, 270, 90);
gp.AddArc(0 + this.Width - CornerRadius, 0 + this.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
gp.AddArc(0, 0 + this.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
this.Region = new Region(gp);
}
تم تعديل هذه المشاركة بواسطة SOLO.NET في 5 ديسمبر 2013 في 01:52
VB.NET and C# Comparison
http://www.harding.edu/fmccown/vbnet_csharp_comparison.html
=-=-=-=-=-=-=
ذو العلم يشقى فى النعيم بعلمه .:. واخو الجهالة فى الشقاوة ينعم
=-=-=-=-=-=-=
يا من بدنياه اشتغل . قد غره طول الأمل . فالموت يأتى بغتة . والقبر صندوق العمل
=-=-=-=-=-=-=
ان لم تستطع ان تجد ما تفعله فافعل ما لم تسطع ان تجده

SOLO.NET كتب:private void Form1_Paint(object sender, PaintEventArgs e) { //Form Property this.FormBorderStyle = FormBorderStyle.None; this.MaximizeBox = false; this.MinimizeBox = false; this.Width = 500; this.Height = 500; this.BackColor = Color.CadetBlue; this.StartPosition = FormStartPosition.CenterScreen; //Create round Edge Using GDI+.net //using System.Drawing.Drawing2D; int CornerRadius = 150; GraphicsPath gp = new GraphicsPath(); gp.AddArc(0, 0, CornerRadius, CornerRadius, 180, 90); gp.AddArc(0 +this.Width - CornerRadius, 0, CornerRadius, CornerRadius, 270, 90); gp.AddArc(0 + this.Width - CornerRadius, 0 + this.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90); gp.AddArc(0, 0 + this.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90); this.Region = new Region(gp); }
شكراً اخي علي الرد
بعد تنفيذ الكود اصبح الفورم يختفي ويظهر بسرعة شديدة وكأنه يومض ..
استخدم نفس الكود فى الحدث Load بدلا من Paint
private void Form1_Load(object sender, EventArgs e)
{
//Form Property
this.FormBorderStyle = FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Width = 500;
this.Height = 500;
this.BackColor = Color.CadetBlue;
this.StartPosition = FormStartPosition.CenterScreen;
//Create round Edge Using GDI+.net
//using System.Drawing.Drawing2D;
int CornerRadius = 150;
GraphicsPath gp = new GraphicsPath();
gp.AddArc(0, 0, CornerRadius, CornerRadius, 180, 90);
gp.AddArc(0 + this.Width - CornerRadius, 0, CornerRadius, CornerRadius, 270, 90);
gp.AddArc(0 + this.Width - CornerRadius, 0 + this.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
gp.AddArc(0, 0 + this.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
this.Region = new Region(gp);
}VB.NET and C# Comparison
http://www.harding.edu/fmccown/vbnet_csharp_comparison.html
=-=-=-=-=-=-=
ذو العلم يشقى فى النعيم بعلمه .:. واخو الجهالة فى الشقاوة ينعم
=-=-=-=-=-=-=
يا من بدنياه اشتغل . قد غره طول الأمل . فالموت يأتى بغتة . والقبر صندوق العمل
=-=-=-=-=-=-=
ان لم تستطع ان تجد ما تفعله فافعل ما لم تسطع ان تجده
