05-08-13, 07:03 PM
السلام عليكم ورحمة الله وبركاته
الأدوات نوعان
أداة تحكم Control
أداة مكوّن Component
في كلا الأداة إذا أردت تغيير مباشر على الفورم لا بد من الحصول على مقبض الفورم الذي تم وضع الأداة عليه بشكل تلقائي
وهذا إجراء جاهز من مكتبتي يشمل حدث Pain وResize، ضعه داخل الأداة وسيكون ParentForm هو مقبض الفورم
PHP كود :
#Region " ParentForm "
Private _Form As Form = Nothing
<Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
Public Property ParentForm() As Form
Get
Return _Form
End Get
Set(ByVal value As Form)
_Form = DirectCast(value, Form)
SetDoubleBuffering(ParentForm, True)
AddHandler ParentForm.Paint, AddressOf Form_Paint
AddHandler ParentForm.Resize, AddressOf Form_Resize
ParentForm.Invalidate()
End Set
End Property
Private Sub SetDoubleBuffering(ByVal frm As Form, ByVal value As Boolean)
Dim p As System.Reflection.PropertyInfo = frm.GetType.GetProperty("DoubleBuffered", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic)
p.SetValue(frm, value, Nothing)
End Sub
Public Overrides Property Site() As ISite
Get
Return MyBase.Site
End Get
Set(ByVal value As ISite)
MyBase.Site = value
If value Is Nothing Then
Return
End If
Dim host As IDesignerHost = TryCast(value.GetService(GetType(IDesignerHost)), IDesignerHost)
If host IsNot Nothing Then
Dim componentHost As IComponent = host.RootComponent
If TypeOf componentHost Is ContainerControl Then
ParentForm = TryCast(componentHost, Form)
End If
End If
End Set
End Property
Private Sub Form_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
sender.ForeColor = Color.White
sender.BackColor = Color.FromArgb(62, 62, 62)
e.Graphics.Clear(Color.FromArgb(62, 62, 62))
End Sub
Private Sub Form_Resize(ByVal sender As Object, ByVal e As System.EventArgs)
ParentForm.Invalidate()
End Sub
#End Region
السلام عليكم ورحمة الله وبركاته
