تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
مقال- تطوير الفورم رسم الفورم باستخدام +GDI وتحريكه Moving و تغيير أبعاده Resize
#3
بالنسبة لمستخدمي نسخة الفيجوال استوديو 2005 يمكنهم فتح فورم وفي الفورم كود يمكنهم نسخ الكود الأتي ووضعه في الفورم رقم واحد
وسيحصلون علي نفس النتائج


كود :
'
'
' By Omar amin
' Greetings from Egypt
' e-mail (silverlight1212@yahoo.com)
'
'
Public Class Form1

#Region "Constants"

' Define Hit Test Constants refer to "windows.h" header file
' Non Client Area Hit Test
Friend Const WM_NCHITTEST As Integer = &H84

' Hit Test in Caption Rectangle
Friend Const HTCAPTION As Integer = &H2

' Hit Test in Left Rectangle
Friend Const HTLEFT As Integer = &HA

' Hit Test in Right Rectangle
Friend Const HTRIGHT As Integer = &HB

' Hit Test in Top Rectangle
Friend Const HTTOP As Integer = &HC

' Hit Test in Top Left Rectangle
Friend Const HTTOPLEFT As Integer = &HD

' Hit Test in Top Right Rectangle
Friend Const HTTOPRIGHT As Integer = &HE

' Hit Test in Bottom Rectangle
Friend Const HTBOTTOM As Integer = &HF

' Hit Test in Bottom Left Rectangle
Friend Const HTBOTTOMLEFT As Integer = &H10

' Hit Test in Bottom right Rectangle
Friend Const HTBOTTOMRIGHT As Integer = &H11

#End Region

#Region "Methods"

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
'
' First let us Draw the Background of the form
Dim winBounds As New Rectangle(0, 0, Me.Width, Me.Height)
Using brush As New System.Drawing.Drawing2D.LinearGradientBrush(winBounds, Color.LightCoral, Color.Red, 90, True)

e.Graphics.FillRectangle(brush, winBounds)

End Using

' Let us Paint the Other Rectangles
Dim NC_Rectangles As Rectangle() = {New Rectangle(5, 5, ClientSize.Width - 10, 24), _
New Rectangle(6, 0, ClientSize.Width - 12, 5), _
New Rectangle(0, 0, 6, 6), _
New Rectangle(ClientSize.Width - 6, 0, 6, 6), _
New Rectangle(0, 6, 5, ClientSize.Height - 12), _
New Rectangle(ClientSize.Width - 5, 6, 5, ClientSize.Height - 12), _
New Rectangle(6, ClientSize.Height - 5, ClientSize.Width - 12, 5), _
New Rectangle(0, ClientSize.Height - 6, 6, 6), _
New Rectangle(ClientSize.Width - 6, ClientSize.Height - 6, 6, 6)}

Using NC_Brush As New SolidBrush(Color.FromArgb(255, Color.DarkBlue))

e.Graphics.FillRectangles(NC_Brush, NC_Rectangles)

End Using


' Draw some Text too
Dim r As Rectangle = Me.ClientRectangle
Dim sf As New StringFormat
sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center

Dim DrawFont As New Font(Font.FontFamily, 40, FontStyle.Regular, GraphicsUnit.Pixel)
ControlPaint.DrawStringDisabled(e.Graphics, "Hello World", DrawFont, BackColor, RectangleF.op_Implicit(r), sf)

End Sub

Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
MyBase.OnResize(e)

Invalidate()

End Sub

<System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.LinkDemand, Flags:=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)> _
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

If Not DesignMode Then

Dim m_Point As Point

' Define Hit Test Imaginary Rectangles
Dim CaptionRect As New Rectangle(5, 5, ClientSize.Width - 10, 24)

Dim TopRect As New Rectangle(6, 0, ClientSize.Width - 12, 5)
Dim TopLeftRect As New Rectangle(0, 0, 6, 6)
Dim TopRightRect As New Rectangle(ClientSize.Width - 6, 0, 6, 6)

Dim LeftRect As New Rectangle(0, 6, 5, ClientSize.Height - 12)
Dim RightRect As New Rectangle(ClientSize.Width - 5, 6, 5, ClientSize.Height - 12)

Dim BottomRect As New Rectangle(6, ClientSize.Height - 5, ClientSize.Width - 12, 5)
Dim BottomLeftRect As New Rectangle(0, ClientSize.Height - 6, 6, 6)
Dim BottomRightRect As New Rectangle(ClientSize.Width - 6, ClientSize.Height - 6, 6, 6)

Select Case m.Msg

Case WM_NCHITTEST
m_Point = PointToClient(New Point(m.LParam.ToInt32()))

If CaptionRect.Contains(m_Point) Then

m.Result = CType(HTCAPTION, IntPtr)
Return

ElseIf TopRect.Contains(m_Point) Then

m.Result = CType(HTTOP, IntPtr)
Return

ElseIf LeftRect.Contains(m_Point) Then

m.Result = CType(HTLEFT, IntPtr)
Return

ElseIf RightRect.Contains(m_Point) Then

m.Result = CType(HTRIGHT, IntPtr)
Return

ElseIf TopLeftRect.Contains(m_Point) Then

m.Result = CType(HTTOPLEFT, IntPtr)
Return

ElseIf TopRightRect.Contains(m_Point) Then

m.Result = CType(HTTOPRIGHT, IntPtr)
Return

ElseIf BottomRect.Contains(m_Point) Then

m.Result = CType(HTBOTTOM, IntPtr)
Return

ElseIf BottomLeftRect.Contains(m_Point) Then

m.Result = CType(HTBOTTOMLEFT, IntPtr)
Return

ElseIf BottomRightRect.Contains(m_Point) Then

m.Result = CType(HTBOTTOMRIGHT, IntPtr)
Return

End If

Exit Select

End Select

End If

MyBase.WndProc(m)


End Sub


#End Region



End Class



أتمني للجميع التوفيق
أخوكم عمر
}}}
تم الشكر بواسطة:


الردود في هذا الموضوع
مقال- تطوير الفورم رسم الفورم باستخدام +GDI وتحريكه Moving و تغيير أبعاده Resize - بواسطة Raggi Tech - 05-10-12, 07:00 PM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
Rainbow [VB.NET] كلاس ResizeControls وطريقة جديد ومميزة لتكبير وتصغير ادوات الفورم تلقائيا الماجيك مسعد 9 10,544 19-07-25, 05:59 PM
آخر رد: Mostafa25
Video [درس فيديو] حل مشكلة تغيير مسار قاعدة البيانات مع تقارير كريستال ريبورت رمضان272 1 2,476 25-10-24, 04:53 AM
آخر رد: رمضان272
  حساب مكان الفورم علي شاشة الكمبيوتر silverlight 2 3,617 18-06-23, 03:26 PM
آخر رد: kebboud
  التعامل مع الصور Images في بيئة الدوت نت باستخدام +GDI - مقدمة RaggiTech 3 6,341 30-07-21, 05:14 PM
آخر رد: kebboud
  مقال: الكومبو بوكس ComboBox كيف تضيف أيقونات Blue Sky 1 3,452 30-06-19, 10:41 AM
آخر رد: invocker
  [VB.NET] كود يجعل الفورم فى المقدمة دائماً [ بناءاً لطلب احد الاخوة وحتى سيتفاد منه الجميع ] elgokr 5 3,277 16-06-19, 08:32 AM
آخر رد: sendbad100
  اصنع محرر أكواد خاص بك باستخدام الأداة RichTextBox السكر المغرور 13 8,179 19-08-18, 09:27 AM
آخر رد: elgokr
  الفورم بخاصية none محمود صالح 1 2,274 30-12-17, 03:52 AM
آخر رد: طالب برمجة
  رسم الفورم و طباعته silverlight 1 2,668 19-06-17, 05:44 PM
آخر رد: silverlight
  [كود] تغيير دقة الشاشة Basil Abdallah 1 2,853 25-02-17, 05:39 AM
آخر رد: محمد محمود الغرياني

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم