AnnDeletePageMemory 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
// HGLOBAL m_hGlobal
void CVCsampleLoadMemoryDlg::OnButtonAnnfileinfomemory()
{
int nRet;
CString strFormat;
CString strMsg;
long lSize;
short nFormat;
nFormat = ANNFMT_NATIVE;
//Save as the first page of the annotation file
m_hGlobal = 0;
m_Lead1.AnnSaveMemory ((long *)&m_hGlobal, nFormat, FALSE, &lSize, 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);
m_Lead1.AnnSaveMemory ((long *)&m_hGlobal, nFormat, FALSE, &lSize, 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.AnnSaveMemory ((long *)&m_hGlobal, nFormat, FALSE, &lSize, SAVE_APPEND, 0);
//Verify contents of file
nRet = m_Lead1.AnnFileInfoMemory ((long)m_hGlobal, lSize);
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\nTotal Size: %d\n",
strFormat,
m_Lead1.GetAnnInfoVersion (),
m_Lead1.GetAnnInfoTotalPages (),
lSize);
MessageBox(strMsg);
}
else
{
MessageBox("Invalid Annotation Memory File");
}
//Now delete the second page, and display informtion
m_Lead1.AnnDeletePageMemory ((long)m_hGlobal, &lSize, 2);
//Verify contents of file
nRet = m_Lead1.AnnFileInfoMemory ((long)m_hGlobal, lSize);
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\nTotal Size: %d\n",
strFormat,
m_Lead1.GetAnnInfoVersion (),
m_Lead1.GetAnnInfoTotalPages (),
lSize);
MessageBox(strMsg);
}
else
{
MessageBox("Invalid Annotation Memory File");
}
}