Zooming In on a Selection (C++ 5.0 and later)
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. | To add the code for LEAD events, do the following: | |
| 
 | a. | Press Ctrl-W to go to the MFC ClassWizard. | 
| 
 | b. | In the Class Name combo box, select CTutorDlg. | 
| 
 | c. | In the Object IDs list box, select IDC_LEADRASTERVIEW1. | 
| 
 | d. | Continue with the remaining steps for each event. | 
| 3. | In the MFC ClassWizard, double-click the MouseDown event and add code as follows: | |
void CTutorDlg::OnMouseDownLeadrasterview1(short Button, short Shift, float x, float y) 
{
  m_LEADRasterView1.SetAutoRubberBand(TRUE);
  m_LEADRasterView1.SetMousePointer(2);
}
| 4. | In the MFC ClassWizard, double-click the RubberBand event and add code as follows: | 
void CMfc40Dlg::OnRubberBandLeadrasterview1() 
{
  float zoomleft;
  float zoomtop;
  float zoomwidth;
  float zoomheight;
  m_LEADRasterView1.SetMousePointer(0);
  //Zoom in on the selection.
  zoomleft = m_LEADRasterView1.GetRubberBandLeft();
  zoomtop = m_LEADRasterView1.GetRubberBandTop();
  zoomwidth = m_LEADRasterView1.GetRubberBandWidth();
  zoomheight = m_LEADRasterView1.GetRubberBandHeight();
  //zoom in on the rectangle defined by the rubberband
  m_LEADRasterView1.ZoomToRect(zoomleft, zoomtop, zoomwidth, zoomheight);
  m_LEADRasterView1.ForceRepaint();
}
| 5. | Rebuild and run the application. |