AnnSaveMemory example for Visual Basic

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. Add the following to the declarations procedure of the general object in your main form:

Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long

Dim hMem     As Long   ' For WIN16 this would be declared as Integer
Dim iSize    As Long

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:

hMem = 0
If Lead1.AnnSaveMemory (hMem, ANNFMT_NATIVE, False, iSize, SAVE_OVERWRITE, 0) <> 0 Then
   MsgBox ("Error calling AnnSaveMemory")
End If

5. Code the AnnLoadMem button's Click procedure as follows:

'Load the annotations from the memory-resident file.
If Lead1.AnnLoadMemory(hMem, iSize, 1) <> 0 Then
   MsgBox ("Error calling AnnLoadMemory")
Else
   MsgBox ("AnnLoadMemory succeeded")
End If
GlobalFree (hMem)

6. Run your program to test it.