Call Paint Event

bpayne111

Well-known member
Joined
Feb 28, 2003
Messages
326
Location
BFE
When the user clicks the mouse id like to set a couple of variables and then redraw the form.
Should i call the paint event directly or use Me.Refresh?
is thier a difference in using one or the other?
 
You should call Invalidate() then Application.DoEvents() if youre running in a loop, if not, skip the DoEvents part.
 
im using me.refresh as of now and everything is lovly (thanks to posts from this forum)
What is this invalidate you speak of?
im not painting in a loop so i guess it doesnt matter but, im still curious

thanks
 
Refresh forces the component to redraw itself immediately, and it is often not necessary to do this. Invalidate marks the controls surface as invalid, and next time the program is idle (i.e. when you have finished processing) windows will initiate the repaint itself.

Personally I prefer Invalidate. Imagine in a large program you do several things in one loop that require the display to get redrawn. Calling Refresh each time would take time, but once a display is marked invalid you can go on marking it invalid any number of times, it is only redrawn when required.

In a great deal of cases, both work equally well.
 
in my case... i have a loop that defines all my rectangles and images... once the loop is finished im calling me.refresh.

when the mouse moves i reinitialize one value and call refresh again.

im using doublebuffering on the control and i have no flicker at all.

im thining i should stick with me.refresh am i wrong?
 
Back
Top