Results 1 to 13 of 13

Thread: [RESOLVED] Problem with brushs

Threaded View

  1. #1

    Thread Starter
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Resolved [RESOLVED] Problem with brushs

    Hi guys, I got some problem in my project and I hope some one can help. The project is a control library. The user should be able to pass a drawing brush to the controls paint event, therefore I inherited the system PaintEventArgs class and added the Brush property to it.
    Now, the problem is that when a PathGridinentBrush is assigned to the Brush property of the custom-PaintEventArgs the memory usage is growing but if a SolidBrush is used the memory usage stays normal. Also, I want to mention that the custom-PaintEventArgs object is disposed after the use. Here is the class:
    vb Code:
    1. Public Class PaintEventArgs
    2.     Inherits System.Windows.Forms.PaintEventArgs
    3.  
    4.     Private _brush As Brush
    5.     Private _color As Color
    6.  
    7.  
    8.     Public Property Brush() As Brush
    9.         Get
    10.             'If brush is nothing then assign a solid brush
    11.             If Me._brush Is Nothing Then
    12.                 Me._brush = New SolidBrush(Me._color)
    13.             End If
    14.             Return Me._brush
    15.         End Get
    16.         Set(ByVal value As Brush)
    17.             Me._brush = value
    18.         End Set
    19.     End Property
    20.  
    21.  
    22.     Sub New(ByVal brush_color As Color, ByVal graphics As System.Drawing.Graphics, ByVal clipRect As System.Drawing.Rectangle)
    23.         MyBase.New(graphics, clipRect)
    24.         Me._color = brush_color
    25.     End Sub
    26.  
    27.     Protected Overrides Sub Dispose(ByVal disposing As Boolean)
    28.         Try
    29.             If disposing AndAlso Me._brush IsNot Nothing Then
    30.                 Me._brush.Dispose()
    31.             End If
    32.         Finally
    33.             MyBase.Dispose(disposing)
    34.         End Try
    35.     End Sub
    36.  
    37. End Class
    Thanks for any help.
    VBDT

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width