Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
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
 
 
 
TitleMake a simple scribble application
Keywordsscribble, draw
CategoriesGraphics
 
Start drawing in the MouseDown event handler. Continue drawing in MouseMove. End drawing in MouseUp.

This program stores the coordinates of the points drawn in the PointX and PointY arrays.

 
Private PointX() As Single
Private PointY() As Single
Private NumPoints As Integer

Private Drawing As Boolean

Private Sub Form_MouseDown(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    ' Let MouseMove know we are drawing.
    Drawing = True
    
    ' Start from scratch
    NumPoints = 0
    Cls

    ' Start drawing here.
    CurrentX = X
    CurrentY = Y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    ' Make sure we are drawing.
    If Not Drawing Then Exit Sub

    ' Save the new point.
    NumPoints = NumPoints + 1
    ReDim Preserve PointX(1 To NumPoints)
    ReDim Preserve PointY(1 To NumPoints)
    PointX(NumPoints) = X
    PointX(NumPoints) = X

    ' Draw to the point.
    Line -(X, Y)
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    ' Stop drawing.
    Drawing = False
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated