منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : تغيير الزوايا القائمة لرأس النموذج ؟
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
الصفحات : 1 2
بسم الله الرحمن الرحيم

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

قمت بتصميم شكل معين لشكل شاشة البرنامج لدي، ولكن احببت ان اعرف اذا كان بالامكان التغلب على الزوايا القائمة التي هي بأعلى النموذج، وذلك حتى اعطي انطباع اجمل لشكل التصميم.

اعرف ان باستخدام WPF يمكن عمل ذلك بكل سهولة


ولكن سؤالي، كيف لي في ظل تعاملي مع Winform الحصول على زوايا غير قائمة للجزء العلوي من الشاشة .

والف شكر
ماتريد القيام به يعبر بالمصطلح "Rounded corner"

وطبعا توجد دالة API تقوم بفعل ذلك :-


PHP كود :
Private Declare Function CreateRoundRectRgn Lib "Gdi32.dll" Alias "CreateRoundRectRgn" 
(
ByVal nLeftRect As Integer,
ByVal nTopRect As Integer,
ByVal nRightRect As Integer
ByVal nBottomRect As Integer,
ByVal nWidthEllipse As Integer,
ByVal nHeightEllipse As Integer
) As IntPtr 


وطريقة الاستخدام (في حدثForm_load مثلا) :-
PHP كود :
this.Region System.Drawing.Region.FromHrgn(CreateRoundRectRgn(00this.Widththis.Height1111)); 

علما بان الرقم 11 يعبر عن حدة انحناء الزوايا


موفق
السلام عليكم

شكرا اخي / الشاكي لله على اجابتك

قمت بوضع الاجراء الاول في اول شاشة البرنامج

وقمت بوضع السطر في داخل حدث تحميل الفورمط
كود :
this.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, this.Width, this.Height, 11, 11));

ولكن ظهرت اخطاء لي بعدم تقبل الاكواد

هل هناك شي اخر لازم اعمله

ارجو الاطلاع على المثال المرفق والتعديل عليه، خاصة بعد ان وضعت الاكواد التي تفضلت حضرتك بها بداخله، وارشادي الى مكمن الخطأ
بارك الله فيك
ههههه

this هي كلمة خاصة بالسي شارب . توازي Me في الفيجوال بيسك

فاعمل Underscroll للنزول لسطر جديد

يعني جدي

PHP كود :
Private Declare Function CreateRoundRectRgn Lib "Gdi32.dll" Alias "CreateRoundRectRgn" _
(
ByVal nLeftRect As Integer,
ByVal nTopRect As Integer,
ByVal nRightRect As Integer,
ByVal nBottomRect As Integer,
ByVal nWidthEllipse As Integer,
ByVal nHeightEllipse As Integer
 
) As IntPtr 
الف الف شكر
اخي الشاكي لله على التوضيح

نحجت الاكواد التي تفضلت بها، وفعلا اصبحت الزاوية اليسارية للنموذج غير قائمة


ولكن مادا عساي افعل حتى اعدل الزاوية اليمنى ايضا ؟؟

بارك الله فيك
والله الكود عندي تمام التمام

واستخدمه منزمان

ربما لأنك تتعامل مع mdi form فتختلف الامور
شكرا اخي
الشاكي لله على اجابتك

إقتباس :ربما لأنك تتعامل مع mdi form فتختلف الامور

الشاشة هي شاشة محتضنة ضمن الشاشة الرئيسية، ومعظم شاشات برامجنا سوف تكون كدلك

ما الحل للتغلب على تلك المعضلة ؟
اخيرا وجدت كلاس ممتازة على النت ...

اضفها

PHP كود :
Public Class RoundedRectangle
    
Public Enum RectangleCorners
        None 
0
        TopLeft 
1
        TopRight 
2
        BottomLeft 
4
        BottomRight 
8
        All 
TopLeft Or TopRight Or BottomLeft Or BottomRight
    End Enum

    
Public Shared Function Create(As IntegerAs Integerwidth As Integerheight As Integer_
 radius 
As Integercorners As RectangleCorners) As GraphicsPath
        Dim xw 
As Integer width
        Dim yh 
As Integer height
        Dim xwr 
As Integer xw radius
        Dim yhr 
As Integer yh radius
        Dim xr 
As Integer radius
        Dim yr 
As Integer radius
        Dim r2 
As Integer radius 2
        Dim xwr2 
As Integer xw r2
        Dim yhr2 
As Integer yh r2

        Dim p 
As New GraphicsPath()
        
p.StartFigure()

        
'Top Left Corner
        If (RectangleCorners.TopLeft And corners) = RectangleCorners.TopLeft Then
            p.AddArc(x, y, r2, r2, 180, 90)
        Else
            p.AddLine(x, yr, x, y)
            p.AddLine(x, y, xr, y)
        End If

        '
Top Edge
        p
.AddLine(xryxwry)

        
'Top Right Corner
        If (RectangleCorners.TopRight And corners) = RectangleCorners.TopRight Then
            p.AddArc(xwr2, y, r2, r2, 270, 90)
        Else
            p.AddLine(xwr, y, xw, y)
            p.AddLine(xw, y, xw, yr)
        End If

        '
Right Edge
        p
.AddLine(xwyrxwyhr)

        
'Bottom Right Corner
        If (RectangleCorners.BottomRight And corners) = RectangleCorners.BottomRight Then
            p.AddArc(xwr2, yhr2, r2, r2, 0, 90)
        Else
            p.AddLine(xw, yhr, xw, yh)
            p.AddLine(xw, yh, xwr, yh)
        End If

        '
Bottom Edge
        p
.AddLine(xwryhxryh)

        
'Bottom Left Corner
        If (RectangleCorners.BottomLeft And corners) = RectangleCorners.BottomLeft Then
            p.AddArc(x, yhr2, r2, r2, 90, 90)
        Else
            p.AddLine(xr, yh, x, yh)
            p.AddLine(x, yh, x, yhr)
        End If

        '
Left Edge
        p
.AddLine(xyhrxyr)

        
p.CloseFigure()
        Return 
p
    End 
Function

    Public 
Shared Function Create(rect As Rectangleradius As IntegerAs RectangleCorners) As GraphicsPath
        
Return Create(rect.Xrect.Yrect.Widthrect.Heightradiusc)
    
End Function

    Public 
Shared Function Create(As IntegerAs Integerwidth As Integerheight As Integerradius As Integer) As GraphicsPath
        
Return Create(xywidthheightradiusRectangleCorners.All)
    
End Function

    Public 
Shared Function Create(rect As Rectangleradius As Integer) As GraphicsPath
        
Return Create(rect.Xrect.Yrect.Widthrect.Heightradius)
    
End Function

    Public 
Shared Function Create(As IntegerAs Integerwidth As Integerheight As Integer) As GraphicsPath
        
Return Create(xywidthheight5)
    
End Function

    Public 
Shared Function Create(rect As Rectangle) As GraphicsPath
        
Return Create(rect.Xrect.Yrect.Widthrect.Height)
    
End Function
End Class 



ثم استخدم هذا الكود في حدث Load وسلامتك

PHP كود :
Dim path As GraphicsPath RoundedRectangle.Create(-1, -1Me.WidthMe.Height11)
Me.Region = New Region(path
شكرا اخي
الشاكي لله على تواصلك معي لايجاد حل

تم وضع الكود الاول الذي تفضلت به حضرتك ضمن كلاس

الا ان هناك رسائل خطأ قد ظهرت لدي، كما هو موضح بالصورة المرفقة

ارجو التوضيح
بارك الله فيك
شوف اخي بعلمك حركة بتستفيد منها إلى اخر يوم تبرمج فيه

لأن اغلب الناس الي يحطون الاكواد في الانترنت ، ينسون يقولون لك "قم باستيراد المكتبات الضرورية"

يعني سو import للمكتبة

فالخلل هنا انك لم تستورد المكتبة System.Drawing.Drawing2D



--


انا بعلمك طريقة حلوة واكثر الناس تستخدمها الا وهي : تحرك الماوس نحو الخط الاحمر الصغير .. ثم تضغط Import.......

شوف الصورة المتحركة





اذا ماظهرت قم بتحميلها من هنا :

إقتباس :http://www.gulfup.com/?ogvum0
الصفحات : 1 2