AnnDeletePageArray example for C++ 5.0 and later
//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
//Assume the following is a member variable of the class
// VARIANT m_AnnVariant
void CVCsampleLoadMemoryDlg::OnButtonAnnfileinfoarray()
{
int nRet;
CString strFormat;
CString strMsg;
short nFormat;
nFormat = ANNFMT_NATIVE;
VariantInit(&m_AnnVariant);
//Save as the first page of the annotation file
nRet = m_Lead1.AnnSaveArray (&m_AnnVariant, nFormat, FALSE, SAVE_OVERWRITE, 0);
//Flip the container, and save as the second page (insert before page 2)
m_Lead1.AnnFlip (TRUE, m_Lead1.GetBitmapHeight() / 2, FALSE);
nRet = m_Lead1.AnnSaveArray (&m_AnnVariant, nFormat, FALSE, 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_Lead1.AnnRotate (FALSE, m_Lead1.GetBitmapWidth () / 2, m_Lead1.GetBitmapHeight() / 2, 45, FALSE);
m_Lead1.AnnSaveArray (&m_AnnVariant, nFormat, FALSE, SAVE_APPEND, 0);
//Verify contents of file
nRet = m_Lead1.AnnFileInfoArray (m_AnnVariant);
if (nRet == 0)
{
switch (m_Lead1.GetAnnInfoFormat ())
{
case ANNFMT_NATIVE:
strFormat = "ANNFMT_NATIVE";
break;
case ANNFMT_WMF:
strFormat = "ANNFMT_WMF";
break;
case ANNFMT_ENCODED:
strFormat = "ANNFMT_ENCODED";
break;
default:
strFormat = "Unknown";
break;
}
strMsg.Format("Format: %s\nVersion: %d\nTotal Pages: %d\n",
strFormat,
m_Lead1.GetAnnInfoVersion (),
m_Lead1.GetAnnInfoTotalPages ()
);
MessageBox(strMsg);
}
else
{
MessageBox("Invalid Annotation Memory File");
}
//Now delete the second page, and display informtion
m_Lead1.AnnDeletePageArray (&m_AnnVariant, 2);
//Verify contents of file
nRet = m_Lead1.AnnFileInfoArray (m_AnnVariant);
if (nRet == 0)
{
switch (m_Lead1.GetAnnInfoFormat ())
{
case ANNFMT_NATIVE:
strFormat = "ANNFMT_NATIVE";
break;
case ANNFMT_WMF:
strFormat = "ANNFMT_WMF";
break;
case ANNFMT_ENCODED:
strFormat = "ANNFMT_ENCODED";
break;
default:
strFormat = "Unknown";
break;
}
strMsg.Format("Format: %s\nVersion: %d\nTotal Pages: %d\n",
strFormat,
m_Lead1.GetAnnInfoVersion (),
m_Lead1.GetAnnInfoTotalPages ()
);
MessageBox(strMsg);
}
else
{
MessageBox("Invalid Annotation Memory File");
}
//if finished with m_AnnVariant, free the memory by calling VariantClear
}