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
 
 
 
TitleLet the user drag a vertical line side to side
Keywordsdrag, line, sash, rubberband
CategoriesGraphics
 
Start drawing with DrawMode = vbInvert in the MouseDown event handler. Continue dragging in MouseMove. Stop in MouseUp. Use form-level variables m_X and m_Drawing to record the mouse's current X coordinate and whether we are dragging the line.
 
Dim m_X As Single
Dim m_Drawing As Boolean

Private Sub Form_MouseDown(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    m_Drawing = True
    DrawMode = vbInvert
    DrawWidth = 4
    m_X = X
    Line (m_X, ScaleTop)-(m_X, ScaleHeight)
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    If Not m_Drawing Then Exit Sub
    Line (m_X, ScaleTop)-(m_X, ScaleHeight)
    m_X = X
    Line (m_X, ScaleTop)-(m_X, ScaleHeight)
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    m_Drawing = False
    Line (m_X, ScaleTop)-(m_X, ScaleHeight)
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated