الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

عمل radius للفورم

بدأه كارم سامي في 4 ديسمبر 2013 · 4 رد · 356 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته ،

 

 

كيف اجعل للفورم radius في الاربع اتجهات

#2

السلام عليكم ورحمة الله وبركاته ،

 

وجد الحل ولكن هناك مشكلة بسيطة ارجو منكم افادتي

 

استخدمت هذا الكود

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 غير مستوية تشعر وكأنها مشرشرة .. غير جزابة .. هل هناك حل ؟؟

 

 

post-235772-0-68507500-1386179534.png

#3

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

002.gif

=-=-=-=-=-=-=
ذو العلم يشقى فى النعيم بعلمه .:. واخو الجهالة فى الشقاوة ينعم
=-=-=-=-=-=-=
يا من بدنياه اشتغل . قد غره طول الأمل . فالموت يأتى بغتة . والقبر صندوق العمل
=-=-=-=-=-=-=
ان لم تستطع ان تجد ما تفعله فافعل ما لم تسطع ان تجده

screen_shot_2011-05-19_at_12.44.49_pm.pn

#4
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);
       
        }

 

شكراً اخي علي الرد

 

بعد تنفيذ الكود اصبح الفورم يختفي ويظهر بسرعة شديدة وكأنه يومض ..

#5

استخدم نفس الكود فى الحدث 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);
       
        }
1

VB.NET and C# Comparison

http://www.harding.edu/fmccown/vbnet_csharp_comparison.html

002.gif

=-=-=-=-=-=-=
ذو العلم يشقى فى النعيم بعلمه .:. واخو الجهالة فى الشقاوة ينعم
=-=-=-=-=-=-=
يا من بدنياه اشتغل . قد غره طول الأمل . فالموت يأتى بغتة . والقبر صندوق العمل
=-=-=-=-=-=-=
ان لم تستطع ان تجد ما تفعله فافعل ما لم تسطع ان تجده

screen_shot_2011-05-19_at_12.44.49_pm.pn

مواضيع مشابهة