قمت بتصميم شكل معين لشكل شاشة البرنامج لدي، ولكن احببت ان اعرف اذا كان بالامكان التغلب على الزوايا القائمة التي هي بأعلى النموذج، وذلك حتى اعطي انطباع اجمل لشكل التصميم.
اعرف ان باستخدام WPF يمكن عمل ذلك بكل سهولة
ولكن سؤالي، كيف لي في ظل تعاملي مع Winform الحصول على زوايا غير قائمة للجزء العلوي من الشاشة .
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
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
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(x As Integer, y As Integer, width As Integer, height As Integer, _ radius As Integer, corners As RectangleCorners) As GraphicsPath Dim xw As Integer = x + width Dim yh As Integer = y + height Dim xwr As Integer = xw - radius Dim yhr As Integer = yh - radius Dim xr As Integer = x + radius Dim yr As Integer = y + 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(xr, y, xwr, y)
'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(xw, yr, xw, yhr)
'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(xwr, yh, xr, yh)
'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(x, yhr, x, yr)
p.CloseFigure() Return p End Function
Public Shared Function Create(rect As Rectangle, radius As Integer, c As RectangleCorners) As GraphicsPath Return Create(rect.X, rect.Y, rect.Width, rect.Height, radius, c) End Function
Public Shared Function Create(x As Integer, y As Integer, width As Integer, height As Integer, radius As Integer) As GraphicsPath Return Create(x, y, width, height, radius, RectangleCorners.All) End Function
Public Shared Function Create(rect As Rectangle, radius As Integer) As GraphicsPath Return Create(rect.X, rect.Y, rect.Width, rect.Height, radius) End Function
Public Shared Function Create(x As Integer, y As Integer, width As Integer, height As Integer) As GraphicsPath Return Create(x, y, width, height, 5) End Function
Public Shared Function Create(rect As Rectangle) As GraphicsPath Return Create(rect.X, rect.Y, rect.Width, rect.Height) End Function End Class
ثم استخدم هذا الكود في حدث Load وسلامتك
PHP كود :
Dim path As GraphicsPath = RoundedRectangle.Create(-1, -1, Me.Width, Me.Height, 11) Me.Region = New Region(path)