I have a form that requires drawing custom lines on it. The color of
the lines is suppose to be the same as the forcolor of the form. Am I
doing this the most efficent and correct way? Thanks....
Protected mPen As Pen
Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
If mPen Is Nothing Then mPen = New Pen(Me.ForeColor)
e.Graphics.DrawRectangle(mPen, New Rectangle(5, 5, Me.Width -
10, Me.Height - 10))
e.Graphics.DrawRectangle(mPen, New Rectangle(8, 8, Me.Width -
16, Me.Height - 16))
End Sub
Private Sub PopupTemplate_ForeColorChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles MyBase.ForeColorChanged
If Not mPen Is Nothing Then mPen.Dispose()
mPen = New Pen(Me.ForeColor)
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
if not mPen is Nothing then mPen.dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub