AnnSaveMemory example for Delphi

Note:

This topic is for Document/Medical only.

This example lets you save the current annotations to a file in memory, and lets you load the annotations that were saved.

1.

Start with the project that you created in Creating and Using Annotations.

2.

Declare the following in the private section of your main form:

hMemGlobal: longint;
iSizeGlobal: longint;

3.

Add the following code to the main form's Load procedure

RasterAnn:= CoLEADRasterAnnotation.Create ();

4.

image\btncmd.gif At the top of your main form, add two command buttons and name them as follows:

 

Name

Caption

 

AnnSaveMem

Save In Memory

 

AnnLoadMem

Load From Memory

5.

Code the AnnSaveMem button's Click procedure as follows:

procedure TForm1.AnnSaveMemClick(Sender: TObject);
begin
   if (RasterAnn.AnnSaveMemory (hMemGlobal, ANN_FMT_NATIVE, False, iSizeGlobal) <> 0) then
      ShowMessage ('Error calling AnnSaveMemory');
end;

6.

Code the AnnLoadMem button's Click procedure as follows:

//Load the annotations from the memory-resident file.
procedure TForm1.AnnLoadMemClick(Sender: TObject);
begin
   if RasterAnn.AnnLoadMemory (hMemGlobal, iSizeGlobal) <> 0 Then
      ShowMessage ('Error calling AnnLoadMemory')
   else
      ShowMessage ('AnnLoadMemory succeeded');
   GlobalFree (hMemGlobal);
end;

7.

Run your program to test it.