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 dockable toolbar
Keywordsdockable, ToolBar
CategoriesTips and Tricks, Controls
 
In the toolbar's MouseUp event handler, see which edge of the form is closest to the mouse. Dock the toolbar on that edge.

Unfortunately the program does not give visual feedback while the user drags the mouse.

 
' See which edge is closest to the mouse.
Private Sub Toolbar1_MouseUp(Button As Integer, Shift As _
    Integer, x As Single, y As Single)
Dim dist_to_top As Single
Dim dist_to_left As Single
Dim dist_to_right As Single
Dim dist_to_bottom As Single
Dim smallest As Single

    ' See which is closest.
    dist_to_top = Toolbar1.Top + y
    dist_to_left = Toolbar1.Left + x
    dist_to_right = Toolbar1.Left + ScaleWidth - x
    dist_to_bottom = Toolbar1.Top + ScaleHeight - y
    smallest = dist_to_top
    If smallest > dist_to_left Then smallest = dist_to_left
    If smallest > dist_to_right Then smallest = _
        dist_to_right
    If smallest > dist_to_bottom Then smallest = _
        dist_to_bottom

    ' Move the toolbar.
    If dist_to_left = smallest Then
        Toolbar1.Align = vbAlignLeft
    ElseIf dist_to_top = smallest Then
        Toolbar1.Align = vbAlignTop
    ElseIf dist_to_right = smallest Then
        Toolbar1.Align = vbAlignRight
    Else
        Toolbar1.Align = vbAlignBottom
    End If
End Sub
 
Formatted by Neil Crosby
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated