Product : Standard, Version : 4.0.1.1018, ArticleID : 41018073

HowTo : Controling the Pan and the Scroll Bars.

Article41018073
TypeHowTo
ProductStandard
Version4.0.1.1018
Date Added4/14/2003
Submitted byBob Hosea
Keywords

Subject

Controling the Pan and the Scroll Bars.

Summary

How can I get the scroll bars in the vector draw control to only scroll the picture area and not scroll off into vast unknown on the sides of the diagram. I want to have the scroll bars stop when the edge of the diagram is reached. I don't want it to scroll beyond the edges of the diagram.

Solution

You can use the ScrollView event to control this. See the VB 6.0 Code below:

Private Sub VD_ScrollView(dx As Double, dy As Double, Cancel As Integer)
Dim TargPt      As Variant
Dim VHeight     As Double
Dim VWidth      As Double
Dim Ext         As Variant

    Ext = VD.ActiveDocument.GetBoundExtends
    VHeight = VD.ActiveDocument.ViewSize
    VWidth = VD.ActiveDocument.ViewWidth
    If dx > 0 Then
        If Ext(0) > VD.ActiveDocument.OriginX - VWidth / 2# Then dx = 0
    End If
    If dx < 0 Then
        If Ext(2) < VD.ActiveDocument.OriginX + VWidth / 2# Then dx = 0
    End If
    If dy < 0 Then
        If Ext(1) > VD.ActiveDocument.OriginY - VHeight / 2# Then dy = 0
    End If
    If dy > 0 Then
        If Ext(3) < VD.ActiveDocument.OriginY + VHeight / 2# Then dy = 0
    End If
End Sub