Discussion:
VB6 and Picturebox
(too old to reply)
Chris
2004-10-25 16:54:19 UTC
Permalink
I'm working with VB6.
I'm putting about 5000 points in a pictrebox. It takes a long time because
of Autoredraw = true in the picturebox.

If I set autoredraw = false it's very very faster, but if I open a new
window in front of the picturebox, everything disappear.
I have try this :
- set autoredraw = false
- draw picture
- set autoredraw = true

but autoredraw doesn't works.

What must I do to get advantage of autoredraw without the lack of time ?

thanks in advance
chris
Mike D Sutton
2004-10-25 17:45:26 UTC
Permalink
Post by Chris
I'm working with VB6.
I'm putting about 5000 points in a pictrebox. It takes a long time because
of Autoredraw = true in the picturebox.
If I set autoredraw = false it's very very faster, but if I open a new
window in front of the picturebox, everything disappear.
- set autoredraw = false
- draw picture
- set autoredraw = true
but autoredraw doesn't works.
What must I do to get advantage of autoredraw without the lack of time ?
Draw in the Paint() event of the picture box, and call it's .Refresh() method when you require a re-draw.
To be honest though 5000 points shouldn't take _that_ long to render, which method are you using to draw them?
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: ***@mvps.org
WWW: Http://EDais.mvps.org/
Chris
2004-10-26 06:11:53 UTC
Permalink
I'm using "PaintPicture" method.
Post by Mike D Sutton
Post by Chris
I'm working with VB6.
I'm putting about 5000 points in a pictrebox. It takes a long time because
of Autoredraw = true in the picturebox.
If I set autoredraw = false it's very very faster, but if I open a new
window in front of the picturebox, everything disappear.
- set autoredraw = false
- draw picture
- set autoredraw = true
but autoredraw doesn't works.
What must I do to get advantage of autoredraw without the lack of time ?
Draw in the Paint() event of the picture box, and call it's .Refresh()
method when you require a re-draw.
Post by Mike D Sutton
To be honest though 5000 points shouldn't take _that_ long to render,
which method are you using to draw them?
Post by Mike D Sutton
Hope this helps,
Mike
- Microsoft Visual Basic MVP -
WWW: Http://EDais.mvps.org/
Mike D Sutton
2004-10-26 09:02:05 UTC
Permalink
Post by Chris
I'm using "PaintPicture" method.
Well done? It doesn't make any difference to where you're performing the painting though. If you paint in the Paint() event
handler of the control then when the window is uncovered it will trigger the event and the control will be re-drawn.
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: ***@mvps.org
WWW: Http://EDais.mvps.org/

Larry Serflaten
2004-10-25 18:37:05 UTC
Permalink
Post by Chris
I'm working with VB6.
I'm putting about 5000 points in a pictrebox. It takes a long time because
of Autoredraw = true in the picturebox.
What must I do to get advantage of autoredraw without the lack of time ?
Hide a picturebox with its AutoRedraw set and draw to that, then when done,
move that to your form so it can leave its AutoRedraw set to False.

For an example, add a picturebox to a new form, and paste in the code below:
Click on the form to add points....

HTH
LFS


Private Sub Form_Load()
Picture1.Visible = False
Picture1.AutoRedraw = True
Picture1.Move 0, 0, 6000, 6000
Picture1.BackColor = vbBlack
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim dst As Single, ang As Single, cnt As Single
dst = 20
For ang = 0 To 600 Step 0.12
Picture1.PSet (Sin(ang) * dst + X, Cos(ang) * dst + Y), vbWhite
dst = dst * 1.0006 + 0.02
cnt = cnt + 1
Next

Me.Picture = Picture1.Image
Caption = cnt & " Points added"

End Sub

Private Sub Form_Paint()
Static Busy As Boolean
If Busy Then Exit Sub
Busy = True
Me.Picture = Picture1.Image
Busy = False

End Sub
Continue reading on narkive:
Loading...