AnnSaveMemory example for C++ 5.0 and later

Note: This topic is for Document/Medical only.

For more information on declaration and unlocking procedures used in testing this example, refer to Annotation Declaration Information.

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.

Edit TUTORDLG.H and insert the following lines in the definition of CTutorDlg after DECLARE_MESSAGE_MAP():

HGLOBAL m_hMem;
long m_iSize;

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:

void CMfc40Dlg::OnAnnSaveMem() 
{
   if (m_pRasterAnn->AnnSaveMemory((long FAR *)&m_hMem, ANN_FMT_NATIVE, VARIANT_FALSE, &m_iSize, SAVE_OVERWRITE, 0) != 0)
      AfxMessageBox(TEXT("Error calling AnnSaveMemory"));
}

5.

Code the AnnLoadMem button's Click procedure as follows:

void CMfc40Dlg::OnAnnLoadMem() 
{
   //Load the annotations from the memory-resident file.
   if ((m_pRasterAnn->AnnLoadMemory((OLE_HANDLE)m_hMem, m_iSize, 1) != 0))
      AfxMessageBox(TEXT("Error calling AnnLoadMemory"));
   else
      AfxMessageBox(TEXT("AnnLoadMemory succeeded"));
   ::GlobalFree(m_hMem);
}

6.

Run your program to test it.