"Tim" <Ci************@gmail.com> wrote in message
news:11**********************@b68g2000cwa.googlegr oups.com...
interesting.
how do I limit when the onpaint gets called?
say I want to click a button to draw something.
also, I am drawing hundreds of circles on the form. I still think it
would be better to draw them to something in memory, and then dump the
finished thing to the form.
any tips?
Ok, you really don't want to limit when onpaint gets called:
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e) ' This line will cause the form/control to paint
' itself. This also raised the Paint event for
' the form/control.
' Perform you custom paint functions here.
End Sub
What you can do, then, is to create a bitmap object and draw on that object
(of course, you'll need to create your own Graphics class to do this) and
then draw the bitmap onto the form/control using the Graphics object
provided by the OnPaint method. I'm not sure if it is faster though, since
you are creating another instance of the Graphics object on every
call...maybe, instead, you can somehow prevent the actual rendering of the
drawing until you have completed drawing the circles.
You can force the OnPaint method to be called by invalidating the client
area of the form (or just the region you want to repaint) by calling one of
the Invalidate method overloads for the form/control.
I'll check into it and get back to ya via ng.
HTH,
Mythran