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:
Thanks for any help.vb Code:
Public Class PaintEventArgs Inherits System.Windows.Forms.PaintEventArgs Private _brush As Brush Private _color As Color Public Property Brush() As Brush Get 'If brush is nothing then assign a solid brush If Me._brush Is Nothing Then Me._brush = New SolidBrush(Me._color) End If Return Me._brush End Get Set(ByVal value As Brush) Me._brush = value End Set End Property Sub New(ByVal brush_color As Color, ByVal graphics As System.Drawing.Graphics, ByVal clipRect As System.Drawing.Rectangle) MyBase.New(graphics, clipRect) Me._color = brush_color End Sub Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso Me._brush IsNot Nothing Then Me._brush.Dispose() End If Finally MyBase.Dispose(disposing) End Try End Sub End Class
VBDT




Reply With Quote