Zooming In on a Selection (C++ Builder 6.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.

Handle the LEADRasterView1 control's OnMouseDown2 event, and code LEADRasterView1MouseDown2 as follows:

void __fastcall TForm1::LEADRasterView1MouseDown2(TObject *Sender, short Button, short Shift, long x, long y)
{
   //Enable AutoRubberBand
   LEADRasterView1->AutoRubberBand = true; 
   LEADRasterView1->MousePointer = 2; 
}

3.

Handle the LEADRasterView1 OnRubberBand event, and code LEADRasterView1RubberBand procedure, as follows:

void __fastcall TForm1::LEADRasterView1RubberBand(TObject *Sender) 
{
   int zoomleft; 
   int zoomtop;
   int zoomwidth; 
   int zoomheight; 

   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->Refresh () ;
}

4.

Run your program to test it.