Control Reference > VSPrinter Control > VSPrinter Properties > ScrollLeft Property (VSPrinter) |
Returns or sets the left coordinate of the visible area, in twips.
[form!]VSPrinter.ScrollLeft[ = value As Double ]
The ScrollLeft and ScrollTop properties allow you to control the VSPrinter's scroll bars. You can read these values to determine what part of the preview page the user is looking at, or set them to make a part of the page visible.
When these properties are set, the control validates the ranges automatically and clips the values if necessary. If you assign negative values, the properties are set to zero. If you assign very large values, the properties are set to the maximum value in the scrollbar range.
For example, the following code shows how you can display the top-left or bottom-right corners of a page.
Private Sub cmdTopLeft()
vp.ScrollLeft = 0
vp.ScrollTop = 0
End Sub
Private Sub cmdBottomRight()
vp.ScrollLeft = 32000 ' large value causes maximum to be used
vp.ScrollTop = 32000
End Sub
The following code centers the page on the preview window:
Private Sub cmdCenter()
Dim x, y
x = vp.PageWidth / 2 * (vp.Zoom / 100)
y = vp.PageHeight / 2 * (vp.Zoom / 100)
vp.ScrollLeft = x - (vp.Width - 300) / 2
vp.ScrollTop = y - (vp.Height - 300) / 2
End Sub
The code starts by calculating the position of the page center, then scales it by the current zoom factor. Finally, the code subtracts half the control width, in twips (the 300 factor is the size of the scroll bar, which has to be discounted).
Double