Available in the LEADTOOLS Imaging toolkit. |
Zooming In on a Selection (Visual Basic)
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. In online help, you can use the Edit pull-down menu to copy the block of code.
Private Sub Lead1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'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.