AnnSaveMemory example for Delphi

This example is also for the AnnLoadMemory method

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.

Add the following to the declarations as private members in your main form.

hMem: L_HANDLE; // Memory handle. 
iSize: Longint // size of the file in memory

3.

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

 

4.

Code the AnnSaveMem button's Click procedure as follows:

procedure TForm1.AnnSaveMemClick(Sender: TObject);
begin
if ( LEADAnn1.AnnSaveMemory (@hMem, ANNFMT_NATIVE, False, @iSize, SAVE_OVERWRITE, 0) <> SUCCESS ) then
      ShowMessage ('Error calling AnnSaveMemory');
end;

5.

Code the AnnLoadMem button's Click procedure as follows:

procedure TForm1.AnnLoadMemClick (Sender: TObject);
begin
   //Load the annotations from the memory-resident file.
if ( LEADAnn1.AnnLoadMemory (hMem, iSize, 1) <> SUCCESS) then
      ShowMessage ('Error calling AnnLoadMemory')
   else
      ShowMessage ('AnnLoadMemory succeeded');
   Windows.GlobalFree (hMem);
end;

6.

Run your program to test it.