L_AnnFileInfoOffset

#include "l_bitmap.h"

L_LTANN_API L_INT L_AnnFileInfoOffset(fd, pAnnFileInfo, uStructSize)

L_HFILE fd;

/* Windows file handle of the file to load */

pANNFILEINFO pAnnFileInfo;

/* pointer to a structure */

L_UINT uStructSize;

/* size in bytes, of the structure pointed to by pAnnFileInfo */

Loads information about the annotation file embedded in another file, into the specified ANNFILEINFO structure.

Parameter

Description

fd

The Windows file handle of the file.

pAnnFileInfo

Pointer to the ANNFILEINFO structure to be updated with the annotation file information.

uStructSize

Size in bytes, of the structure pointed to by pAnnFileInfo, for versioning. Use sizeof(ANNFILEINFO).

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function can be used to get information about a LEAD annotation file that is embedded in another file.

To use this function, do the following:

1.

Open the annotation file to get a Windows file handle.

2.

Declare a variable with the datatype of ANNFILEINFO.

3.

Fill in the nSize and nOffset fields of the ANNFILEINFO variable. The field nSize should contain the size of the ANNFILEINFO structure in bytes. The nOffset field should contain the byte location of the first byte of the annotation file.

4.

Call the L_AnnFileInfoOffset function, passing the Windows file handle, and the address of the ANNFILEINFO variable as parameters.

5.

Get the image information from the fields described in ANNFILEINFO structure.

Required DLLs and Libraries

LTDIS

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Win32, x64.

See Also

Functions:

L_AnnFileInfo, L_AnnFileInfoMemory, L_AnnLoad, L_AnnLoadMemory, L_AnnLoadOffset, L_AnnSave, L_AnnSaveOffset, L_AnnSaveMemory

Topics:

Annotation Files

 

Annotation Functions: Input and Output

 

Implementing Annotations

 

Implementing an Automated Annotation Program

 

Implementing a Non-automated Annotation Program

Example

The following example saves an annotation container as the first page of a multi-page annotation file. The format is specified by the 'uFormat' parameter. The file is saved, starting 30 bytes into the file. The container is flipped, and saved as the second page. The container is 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.

L_INT AnnFileInfoOffsetExample(L_TCHAR*     pszFileName,
                               L_UINT32     uFormat,
                               HANNOBJECT   hContainer)
{
   HANDLE         hFile = NULL;
   L_INT          nRet;
   SAVEFILEOPTION SaveFileOption;
   ANNFILEINFO    AnnFileInfo;
   L_TCHAR        szMsg[200];
   L_TCHAR*       pszFormat;
   L_SIZE_T       zSizeWritten;
   L_UINT32       uOffset = 30;
   DWORD          dwSizeWrite;

   hFile  = CreateFile(pszFileName, GENERIC_WRITE | GENERIC_READ , 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);

   WriteFile(hFile, "This is a 29-character string", uOffset, &dwSizeWrite, NULL);

   //Save as the first page of the annotation file
   nRet = L_AnnSaveOffset((L_HFILE) hFile, uOffset, &zSizeWritten, hContainer, uFormat, FALSE, NULL);
   if (nRet != SUCCESS)
      return nRet;

   //Flip the container, and save as the second page (insert before page 2)
   SaveFileOption.uStructSize = sizeof(SAVEFILEOPTION);
   SaveFileOption.Flags = ESO_INSERTPAGE;
   SaveFileOption.PageNumber = 2;

   nRet = L_AnnFlip(hContainer, NULL, ANNFLAG_RECURSE);
   if (nRet != SUCCESS)
      return nRet;

   nRet = L_AnnSaveOffset((L_HFILE) hFile, uOffset, &zSizeWritten, hContainer, uFormat, FALSE, &SaveFileOption);
   if (nRet != SUCCESS)
      return nRet;

   //Rotate the container, and save as the third page
   nRet = L_AnnRotate(hContainer, 45.0, NULL, ANNFLAG_RECURSE);
   if (nRet != SUCCESS)
      return nRet;
   SaveFileOption.PageNumber = 3;
   nRet = L_AnnSaveOffset((L_HFILE) hFile, uOffset, &zSizeWritten, hContainer, uFormat, FALSE, &SaveFileOption);
   if (nRet != SUCCESS)
      return nRet;

   //Verify contents of file
   AnnFileInfo.uStructSize = sizeof(ANNFILEINFO);
   AnnFileInfo.nOffset = uOffset;
   AnnFileInfo.nReserved = 0;
   nRet = L_AnnFileInfoOffset((L_HFILE) hFile, &AnnFileInfo, sizeof(ANNFILEINFO));
   if (nRet != SUCCESS)
      return nRet;

   switch(AnnFileInfo.uFormat)
   {
   case ANNFMT_NATIVE:
      pszFormat = TEXT("ANNFMT_NATIVE");
      break;

   case ANNFMT_WMF:
      pszFormat = TEXT("ANNFMT_WMF");
      break;

   case ANNFMT_ENCODED:
      pszFormat = TEXT("ANNFMT_ENCODED");
      break;

   case ANNFMT_XML:
      pszFormat = TEXT("ANNFMT_XML");
      break;

   default:
      pszFormat = TEXT("Unknown");
      break;
   }

   wsprintf(szMsg,
      TEXT("File[%s]\nVersion[%d]\nFormat[%s]\nTotal Pages[%d]\n"),
      pszFileName, 
      AnnFileInfo.nVersion,
      pszFormat,
      AnnFileInfo.nTotalPages);

   MessageBox(NULL, szMsg, TEXT("Information"), MB_OK);

   //Now delete the second page, and display information
   nRet = L_AnnDeletePageOffset((L_HFILE) hFile, uOffset, 2);

   AnnFileInfo.uStructSize = sizeof(ANNFILEINFO);
   AnnFileInfo.nReserved = 0;
   nRet = L_AnnFileInfoOffset((L_HFILE) hFile, &AnnFileInfo, sizeof(ANNFILEINFO));
   if (nRet != SUCCESS)
      return nRet;
   wsprintf(szMsg,
      TEXT("File[%s]\nVersion[%d]\nFormat[%s]\nTotal Pages[%d]\n"),
      pszFileName, 
      AnnFileInfo.nVersion,
      pszFormat,
      AnnFileInfo.nTotalPages);

   MessageBox(NULL, szMsg, TEXT("Information"), MB_OK);

   CloseHandle(hFile);

   return nRet;
}