Paint, OnPaint and Me.Refresh

bpayne111

Junior Contributor
Joined
Feb 28, 2003
Messages
325
Location
BFE
When writing events for classes should i use the OnEvent method to do my coding and leave the actual event for the user?
For instance OnPaint and Paint... when i paint my control.. which is the correct method to use? my guess would be onpaint... but i'm not sure why.
Also.. Is Me.Refresh the best way to repaint my form? or is there a faster way to accomplish the refresh of my form?
i think i may have asked that second question before...but something makes me feel that me.refresh isn't exactly the fastest way to do it.
 
It doesn't make much difference whether you override OnPaint or listen for the Paint event, usually. The OnPaint function in the base class will do whatever default painting the control has, then it raises the Paint event. If you override OnPaint, the Paint event will never be raised. This is usually only an issue if you want people to be able to listen for your Paint event.

You can use .Refresh or .Invalidate to make your control redraw. I prefer Invalidate, because it doesn't force an immediate redraw, it just marks the surface as invalid so when windows next gets round to it, it will initiate the redraw itself. Also, you can pass a region or rectangle to Invalidate, and only that bit of the surface will be redrawn. This can increase drawing speed.
 
cool thanks divil...
i noticed this post was moved... where did i put it to begin with? i could have sworn i put it in General
 
Back
Top