AnnDeletePageMemory example for C++ Builder
/*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 this global declaration:
L_HANDLE hMem;
void __fastcall TForm1::SampleAnnFileInfoMemoryClick(TObject *Sender)
{
int nRet;
AnsiString strFormat;
AnsiString strMsg;
int lSize;
int uFormat;
uFormat= ANNFMT_NATIVE;
//Save as the first page of the annotation file
hMem= 0;
LEADAnn1->AnnSaveMemory (&hMem, uFormat, False, &lSize, SAVE_OVERWRITE, 0);
//Flip the container, and save as the second page (insert before page 2)
LEADAnn1->AnnFlip (True, LEADAnn1->BitmapHeight / 2, False);
LEADAnn1->AnnSaveMemory (&hMem, uFormat, 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_APP} flag
LEADAnn1->AnnRotate (False, LEADAnn1->BitmapWidth / 2, LEADAnn1->BitmapHeight / 2, 45, False);
LEADAnn1->AnnSaveMemory (&hMem, uFormat, False, &lSize, SAVE_APPEND, 0);
//Verify contents of file
nRet= LEADAnn1->AnnFileInfoMemory (hMem, lSize);
if (nRet == SUCCESS)
{
switch (LEADAnn1->AnnInfoFormat)
{
case ANNFMT_NATIVE:
strFormat = "ANNFMT_NATIVE";
break;
case ANNFMT_WMF:
strFormat = "ANNFMT_WMF";
break;
case ANNFMT_ENCODED:
strFormat = "ANNFMT_ENCODED";
break;
default:
strFormat = "Unknown";
};
strMsg = "";
strMsg = strMsg + "Format: " + strFormat + "\n";
strMsg = strMsg + "Version: " + IntToStr(LEADAnn1->AnnInfoVersion) + "\n";
strMsg = strMsg + "Total Pages: " + IntToStr(LEADAnn1->AnnInfoTotalPages) + "\n";
strMsg = strMsg + "Total Size: " + IntToStr(lSize) + "\n";
ShowMessage (strMsg);
}
else
ShowMessage ("Invalid Annotation Memory File");
//Now delete the second page, and display information
LEADAnn1->AnnDeletePageMemory (hMem, &lSize, 2 );
//Verify contents of file
nRet = LEADAnn1->AnnFileInfoMemory (hMem, lSize);
if (nRet == SUCCESS)
{
switch (LEADAnn1->AnnInfoFormat)
{
case ANNFMT_NATIVE: // Cut command.
strFormat = "ANNFMT_NATIVE";
break;
case ANNFMT_WMF: // Copy command.
strFormat = "ANNFMT_WMF";
break;
case ANNFMT_ENCODED: // Clear command.
strFormat = "ANNFMT_ENCODED";
break;
default:
strFormat = "Unknown";
};
strMsg = "";
strMsg = strMsg + "Format: " + strFormat + "\n";
strMsg = strMsg + "Version: " + IntToStr(LEADAnn1->AnnInfoVersion) + "\n";
strMsg = strMsg + "Total Pages: " + IntToStr(LEADAnn1->AnnInfoTotalPages) + "\n";
strMsg = strMsg + "Total Size: " + IntToStr(lSize) + "\n";
ShowMessage (strMsg);
}
else
ShowMessage ("Invalid Annotation File");
//If finished with hMem, then free the memory by calling GlobalFree
}