AnnDeletePageArray Example for Visual C++
//This sample saves the annotations as the first page of a multipage annotation file in memory
//The annotations are flipped, and saved as the second page
//The annotations are rotated, and saved as the third page
//Information is displayed about the annotation file
//The second page is deleted, and information is again displayed about the annotation file
int nRet;
CString strFormat;
CString strMsg;
VARIANT AnnVariant;
ILEADRasterVariant * pltRasVar = NULL;
CoCreateInstance(CLSID_LEADRasterVariant, NULL, CLSCTX_ALL,
IID_ILEADRasterVariant, (void **)&pltRasVar);
AnnFMTConstants nFormat = ANN_FMT_NATIVE;
//Save as the first page of the annotation file
nRet = m_pRasterAnn->AnnSaveArray(nFormat, FALSE, pltRasVar, SAVE_OVERWRITE, 0);
//Flip the container, and save as the second page (insert before page 2)
m_pRasterAnn->AnnFlip(TRUE, m_RasterView1.GetRaster ().GetBitmapHeight() / 2, FALSE);
nRet = m_pRasterAnn->AnnSaveArray (nFormat, FALSE, pltRasVar, SAVE_INSERT, 2);
//Rotate the container, and save as the third page
//Here we could pass the SAVE_INSERT flag and 3 for nPage,
//but instead we will use the SAVE_APPEND flag
m_pRasterAnn->AnnRotate (FALSE, m_RasterView1.GetRaster ().GetBitmapWidth () / 2, m_RasterView1.GetRaster ().GetBitmapHeight () / 2, 45, FALSE);
m_pRasterAnn->AnnSaveArray (nFormat, FALSE, pltRasVar, SAVE_APPEND, 0);
//Verify contents of file
nRet = m_pRasterAnn->AnnFileInfoArray (pltRasVar);
if (nRet == 0)
{
switch (m_pRasterAnn->GetAnnInfoFormat())
{
case ANN_FMT_NATIVE:
strFormat = TEXT("ANN_FMT_NATIVE");
break;
case ANN_FMT_WMF:
strFormat = TEXT("ANN_FMT_WMF");
break;
case ANN_FMT_ENCODED:
strFormat = TEXT("ANN_FMT_ENCODED");
break;
default:
strFormat = TEXT("Unknown");
break;
}
strMsg.Format(TEXT("Format: %s\nVersion: %d\nTotal Pages: %d\n"),
strFormat,
m_pRasterAnn->GetAnnInfoVersion(),
m_pRasterAnn->GetAnnInfoTotalPages()
);
MessageBox(strMsg);
}
else
{
MessageBox(TEXT("Invalid Annotation Memory File"));
}
//Now delete the second page, and display information
m_pRasterAnn->AnnDeletePageArray(pltRasVar, 2);
//Verify contents of file
nRet = m_pRasterAnn->AnnFileInfoArray(pltRasVar);
if (nRet == 0)
{
switch (m_pRasterAnn->GetAnnInfoFormat())
{
case ANN_FMT_NATIVE:
strFormat = TEXT("ANN_FMT_NATIVE");
break;
case ANN_FMT_WMF:
strFormat = TEXT("ANN_FMT_WMF");
break;
case ANN_FMT_ENCODED:
strFormat = TEXT("ANN_FMT_ENCODED");
break;
default:
strFormat = TEXT("Unknown");
break;
}
strMsg.Format(TEXT("Format: %s\nVersion: %d\nTotal Pages: %d\n"),
strFormat,
m_pRasterAnn->GetAnnInfoVersion (),
m_pRasterAnn->GetAnnInfoTotalPages ()
);
MessageBox(strMsg);
}
else
{
MessageBox(TEXT("Invalid Annotation Memory File"));
}
pltRasVar->Release ();