Zooming In on a Selection (Access 95 and 97)

Take the following steps to add code that lets you select an area with a mouse, and zoom in on the selected area.

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

2. In the Lead1 control's MouseDown procedure, add the following code.

Private Sub Lead1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Long, ByVal Y As Long)
   'Enable AutoRubberBand
   Lead1.AutoRubberBand = True
   Lead1.MousePointer = 2
End Sub

3. In the Lead1 control's RubberBand procedure, add the following code.

Private Sub Lead1_RubberBand()
  Dim zoomleft As Integer
  Dim zoomtop As Integer
  Dim zoomwidth As Integer
  Dim zoomheight As Integer

  Lead1.MousePointer = 0

  'Zoom in on the selection.
  zoomleft = Lead1.RubberBandLeft
  zoomtop = Lead1.RubberBandTop
  zoomwidth = Lead1.RubberBandWidth
  zoomheight = Lead1.RubberBandHeight

  'Zoom in on the rectangle defined by the rubberband
  Lead1.ZoomToRect zoomleft, zoomtop, zoomwidth, zoomheight
  Lead1.ForceRepaint
End Sub

4. Run your program to test it.