Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleDraw a continuous graph similiar to perfmon
Keywordsgraph, continuous graph, scroll, perfmon
CategoriesGraphics
 
Set a PictureBox's scale properties so it covers the range 1-100 vertically. Draw guidelines on it and set picGraph.Picture = picGraph.Image to make the lines permanent.
 
Private Sub Form_Load()
Dim i As Integer

    Randomize
    m_OldValue = 50

    ' Draw on a 1-100 scale vertically and
    ' a pixel scale horizontally.
    picGraph.AutoRedraw = True
    picGraph.ScaleMode = vbPixels
    picGraph.ScaleTop = 100
    picGraph.ScaleHeight = -101

    ' Draw guidelines.
    For i = 20 To 80 Step 20
        picGraph.Line (0, i)-(picGraph.ScaleWidth, i), vbRed
    Next i
    picGraph.Picture = picGraph.Image
End Sub
 
When a timer event executes, use PaintPicture to move the existing graph left. Clear the area on the right, restore its guide lines, and draw the new data.
 
Private Sub tmrGraph_Timer()
Dim new_value As Integer
Dim i As Integer

    ' Move the old data over.
    picGraph.PaintPicture picGraph.Picture, _
        0, 1, picGraph.ScaleWidth - m_Dx, 101, _
        m_Dx, 1, picGraph.ScaleWidth - m_Dx, 101

    ' Erase the right edge and draw guide lines.
    picGraph.Line (picGraph.ScaleWidth - m_Dx, _
        1)-(picGraph.ScaleWidth - 1, 101), _
        picGraph.BackColor, BF
    For i = 20 To 80 Step 20
        picGraph.Line (picGraph.ScaleWidth - m_Dx, _
            i)-(picGraph.ScaleWidth, i), vbRed
    Next i

    ' Plot the new value.
    new_value = NewValue()
    picGraph.Line (picGraph.ScaleWidth - 1 - m_Dx, _
        m_OldValue)-(picGraph.ScaleWidth - 1, new_value)
    m_OldValue = new_value

    picGraph.Picture = picGraph.Image
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated