Niki,
Resources such as brushes created by the form might be disposed (I have not
checked) but I don't believe managed objects/components contained on the
form are. Certainly any objects not added to the components object are not.
Unlike some framework classes Close() does not directly call Dispose(), they
are not the same.
I would suggest that it is best (but not necessarily mandatory) to call
myForm.Dispose() to ensure all managed objects are disposed as soon as
possible. Personally if an object exposes a Dispose() method I always try to
call it at an appropriate time.
The pens/ brushed you have created are I assume the managed objects exposed
by the framework, so they will at some point be reclaimed automatically by
the garbage collection. But to ensure this is done sooner rather than later
then yes I would call their Dispose method as soon as possible, perhaps
doing so in the forms Dispose method. If you don't then the underlying
windows handle will be retained until the GC decides to finally release
them.
Phil...
"Niki Estner" <ni*********@cube.net> wrote in message
news:Ox**************@TK2MSFTNGP11.phx.gbl...
"Mathias L." <ma************@nonospamgxm.de> wrote in
news:ci**********@ls219.htnet.hr...I have two questions for which I couldnt find answer:
If I programaticaly close DialogForm (calling Close()), is it enough or
do I
have to dispose it as MS.NET help says?
Quoted from MSDN, Remarks section about Form.Close:
"When a form is closed, all resources created within the object are closed
and the form is disposed..."
Does that answer your question?
Also, in overriden onPaint method, do I have to dispose pens, brushes and
graphics object or do they got disposed by Framework?
Members of the Pens and Brushes classes will be cleaned by the framework;
You have to clean all the classes you create yourself.
Niki