PageCount Example VC++

This example displays the next page in a multipage file, and determines whether there is another page to display.

void CImgEdit1Dlg::OnNextPage() 
{
    // This would display next page in a multipage file
    long lngNewPg;
        
    lngNewPg = ImgEdit1.GetPage() + 1;
    // Determine if there is a next page to be displayed
    // by finding out the number of pages in the file
    if(lngNewPg > ImgEdit1.GetPageCount())
    {
        AfxMessageBox("Page Number is out of range");
        // Don't set page property
        return;
    }
        
    ImgEdit1.SetPage(lngNewPg);
    ImgEdit1.Display();
}