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 LEADRasterView1 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 LEADRasterView1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
'Enable AutoRubberBand
LEADRasterView1.AutoRubberBand = True
LEADRasterView1.MousePointer = 2
End Sub
3. |
In the LEADRasterView1 control's Rubberband procedure, add the following code. |
Private Sub LEADRasterView1_RubberBand ()
Dim zoomleft As Integer
Dim zoomtop As Integer
Dim zoomwidth As Integer
Dim zoomheight As Integer
LEADRasterView1.MousePointer = 0
'Zoom in on the selection.
zoomleft = LEADRasterView1.RubberBandLeft
zoomtop = LEADRasterView1.RubberBandTop
zoomwidth = LEADRasterView1.RubberBandWidth
zoomheight = LEADRasterView1.RubberBandHeight
'Zoom in on the rectangle defined by the rubberband
LEADRasterView1.ZoomToRect zoomleft, zoomtop, zoomwidth, zoomheight
LEADRasterView1.ForceRepaint
End Sub
4. |
Run your program to test it. |