AnnDeletePageMemory example for Delphi
{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:
var
hMem: L_HANDLE;
procedure TForm1.SampleAnnFileInfoMemoryClick(Sender: TObject);
var
nRet: Integer;
strFormat: String;
strMsg: String;
lSize: Longint;
uFormat: Integer;
begin
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_APPEND 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) Then
begin
Case LEADAnn1.AnnInfoFormat of
ANNFMT_NATIVE:
strFormat := 'ANNFMT_NATIVE';
ANNFMT_WMF:
strFormat := 'ANNFMT_WMF';
ANNFMT_ENCODED:
strFormat := 'ANNFMT_ENCODED';
else
strFormat := 'Unknown';
end;
strMsg := '';
strMsg := strMsg + 'Format: ' + strFormat + Chr(13);
strMsg := strMsg + 'Version: ' + IntToStr(LEADAnn1.AnnInfoVersion) + Chr(13);
strMsg := strMsg + 'Total Pages: ' + IntToStr(LEADAnn1.AnnInfoTotalPages) + Chr(13);
strMsg := strMsg + 'Total Size: ' + IntToStr(lSize) + Chr(13);
ShowMessage (strMsg);
end
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) Then
begin
Case LEADAnn1.AnnInfoFormat of
ANNFMT_NATIVE: // Cut command.
strFormat := 'ANNFMT_NATIVE';
ANNFMT_WMF: // Copy command.
strFormat := 'ANNFMT_WMF';
ANNFMT_ENCODED: // Clear command.
strFormat := 'ANNFMT_ENCODED';
else
strFormat := 'Unknown';
end;
strMsg := '';
strMsg := strMsg + 'Format: ' + strFormat + Chr(13);
strMsg := strMsg + 'Version: ' + IntToStr(LEADAnn1.AnnInfoVersion) + Chr(13);
strMsg := strMsg + 'Total Pages: ' + IntToStr(LEADAnn1.AnnInfoTotalPages) + Chr(13);
strMsg := strMsg + 'Total Size: ' + IntToStr(lSize) + Chr(13);
ShowMessage (strMsg);
end
else
ShowMessage ('Invalid Annotation File');
//If finished with hMem, then free the memory by calling GlobalFree
end;