Zooming In on a Selection (Access 2.0)

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:

Sub Lead1_MouseDown (Button As Integer, Shift As Integer, X As Long, Y As Long)
  'Enable AutoRubberBand
  Me![LEAD1].Object.AutoRubberBand = True
  Me![LEAD1].Object.MousePointer = 2
End Sub

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

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

  Me![LEAD1].Object.MousePointer = 0

  'Zoom in on the selection.
  zoomleft = Me![LEAD1].Object.RubberBandLeft
  zoomtop = Me![LEAD1].Object.RubberBandTop
  zoomwidth = Me![LEAD1].Object.RubberBandWidth
  zoomheight = Me![LEAD1].Object.RubberBandHeight

  'Zoom in on the rectangle defined by the rubberband
  Me![LEAD1].Object.ZoomToRect zoomleft, zoomtop, zoomwidth, zoomheight
  Me![LEAD1].Object.ForceRepaint
End Sub

4. Run your program to test it.