unwanted restarts in paint event

hugohugo37

Member
Joined
May 9, 2006
Messages
8
Programming Experience
Beginner
Hello

Im using the paint event in VB2005 express to draw some mathematical objects. Basically all it is is

for i = 0 to 255
for j=0 to 255

'here I'm just using f1(i,j),f2(i,j),f3(i,j) to represent some mathematical functions of i and j

Dim pencolor As New System.Drawing.Pen(Color.FromArgb(f1(i,j)))

graphicsfun.DrawRectangle(pencolor, f2(i,j), f3(i,j), 2, 2)

nextj
next i

Here's the problem- It draws as it should at first and then the desktop flickers and it starts again. It draws for a bit and then starts again. Usually after several tries it makes it through the loops and stops as it should. The program runs fine on another computer of equal (or even lesser) power. What's going on here? Any insights? Thanks



 
Maybe try:
SetStyle(ControlStyles.DoubleBuffer, True)
SetStyle(ControlStyles.AllPaintingInWmPaint, True)
to get the flickering gone.
 
Back
Top