05-10-12, 07:00 PM
بالنسبة لمستخدمي نسخة الفيجوال استوديو 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أتمني للجميع التوفيق
أخوكم عمر
