ImageWidth Example VC++

This example displays an image and scales it so it fits into the window.  Then it displays the height, width, resolution, scaled height, and scaled width of the image to illustrate the difference between ImageHeight/Width and ImageScaleHeight/Width.

void CImgEdit1Dlg::OnWidthHeight() 
{
    // Displays an image that is fit to window and then displays
    // height, width, resolution, scaled height and scaled width.
    // This illustrates the difference between ImageHeight/Width
    // and ImageScaleHeight/Width.

    VARIANT evt; V_VT(&evt) = VT_ERROR; // set to default
    ImgEdit1.FitTo(0,evt); //BEST_FIT
    ImgEdit1.Display();
             
    CFrmInfo frmInfo;
    
    // Display the dimensions of the image page.
    CString szWindowText;
    long lInfo;

    lInfo = ImgEdit1.GetImageHeight();
    frmInfo.lblImgHeight.Format("%i",lInfo);

    lInfo = ImgEdit1.GetImageWidth();
    frmInfo.lblImgWidth.Format("%i",lInfo);
    
    // Display the X and Y resolution of the image page.
    lInfo = ImgEdit1.GetImageResolutionX();
    frmInfo.lblImgResX.Format("%i",lInfo);

    lInfo = ImgEdit1.GetImageResolutionY();
    frmInfo.lblImgResY.Format("%i",lInfo); 
        
    // Display Image Scale Height
    lInfo = ImgEdit1.GetImageScaleHeight();
    frmInfo.lblImgScaleHeight.Format("%i",lInfo);

    lInfo = ImgEdit1.GetImageScaleWidth();
    frmInfo.lblImgScaleWidth.Format("%i",lInfo);
    
    frmInfo.DoModal();
}