Zooming Out and Zooming In (Access 95 and 97)

Take the following steps to add code that can reduce and enlarge the displayed size of the image. This demonstrates the scaling properties that are normally used for zooming in and zooming out. It emphasizes the relationship of the displayed rectangle to the LEAD control.

1. Start with the project that you created in Loading and Displaying an Image.

2. image\btncmd.gif Add two command buttons to your form and name them as follows:

Name

Caption

ZoomIn

Zoom In

ZoomOut

Zoom Out

3. Click the Code Window icon on the toolbar.

image\btncode.gif For Access 95.

image\btncode2.gif For Access 97.

4. Code the ZoomIn button's click procedure as follows:

Private Sub ZoomIn_Click()
  Lead1.AutoSetRects = True
  Lead1.PaintSizeMode = PAINTSIZEMODE_ZOOM
  Lead1.PaintZoomFactor = Lead1.PaintZoomFactor + 10
End Sub

5. Code the ZoomOut button's click procedure as follows:

Private Sub ZoomOut_Click()
  Lead1.AutoSetRects = True
  Lead1.PaintSizeMode = PAINTSIZEMODE_ZOOM
  If Lead1.PaintZoomFactor > 10 Then
      Lead1.PaintZoomFactor = Lead1.PaintZoomFactor - 10
  End If
End Sub

6. image\btncmpl.gif Click the compile button on the toolbar; then close the code window.

7. Close the form designer, saving the changes.

8. With Form1 selected in the Database window, click the Open button to test the form.