Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- From: "Larry Serflaten" <serflaten@xxxxxxxxxxxxxx>
- Date: Thu, 20 Dec 2007 13:51:06 -0600
"Frank Moyles" <fgmoyles@xxxxxxxxxx> wrote
I have a PictureBox placed on a form, as well as a horizontal scroll
bar. I am drawing a graph (output from an instrument) on the PictureBox.
I am 'scrolling' the graph by dragging the horizontal scroll bar. Each
time the scroll bar changes, I am getting the new values and using that
event to redraw the graph - it works in theory, but in practise, it
flickers quite a lot.
Is there anyway I can eliminate the flickering as I move the scrollbar -
and simply have a "smoothly scrolling" picture as I drag the scrollbar?
How about making the picturebox large enough to hold the entire graph,
and then move the picturebox via the scrollbar events?
For an example, add a Picturebox and HScroll bar to a new form and
paste in the code below....
LFS
Option Explicit
Private Sub Form_Load()
Dim X As Long, c As Long
Picture1.Move 0, 0, 120000, 2000
Picture1.AutoRedraw = True
Picture1.BorderStyle = 0
Picture1.PSet (-1, 1000), vbBlack
Picture1.DrawWidth = 3
For X = 0 To Picture1.Width Step 195
c = c + 1
If c > 50 Then
Picture1.ForeColor = QBColor(Int(Rnd * 16))
c = 0
End If
Picture1.Line -(X, 1000 + Sin(X) * 900)
Next
HScroll1.Min = 0
HScroll1.Max = (Picture1.Width - ScaleWidth) / 100
HScroll1.Move 0, 2120, ScaleWidth, 240
HScroll1.SmallChange = 1
HScroll1.LargeChange = ScaleWidth / 100
End Sub
Private Sub Form_Resize()
HScroll1.Max = (Picture1.Width - ScaleWidth) / 100
HScroll1.Move 0, 2120, ScaleWidth, 240
End Sub
Private Sub HScroll1_Change()
HScroll1_Scroll
End Sub
Private Sub HScroll1_GotFocus()
Picture1.SetFocus
End Sub
Private Sub HScroll1_Scroll()
Picture1.Move CLng(HScroll1.Value) * -100
End Sub
.
- Follow-Ups:
- Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- From: Mike Williams
- Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- References:
- Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- From: Frank Moyles
- Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- Prev by Date: Re: Multiple ListBoxes in one?
- Next by Date: Re: How many apps fail after installation?
- Previous by thread: Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- Next by thread: Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- Index(es):
Relevant Pages
|