AnnGetSecondaryMetafile example for Delphi

Procedure TForm1. AnnGetSecondaryMetafile ( hObject: HANNOBJECT );
var
   nObjectType: L_INT;
   hMetafile1: HMETAFILE;
   hMetafile2: HMETAFILE;
   bEncryptorOriginal: Boolean;

begin
   nObjectType:= LEADAnn1.AnnGetType(hObject);
   if(nObjectType = ANNOBJECT_ENCRYPT) Then
   begin
      ShowMessage('This object is not an encryptor object.');
      Exit;
   end;

   LEADAnn1.AnnGetMetafile(hObject, hMetafile1);
   LEADAnn1.AnnGetSecondaryMetafile(hObject, hMetafile2);

   LEADAnn1.AnnEncryptOptions.Flags:= ANNENCRYPT_ALL;
   LEADAnn1.AnnGetEncryptOptions(hObject);

   bEncryptorOriginal:= LEADAnn1.AnnEncryptOptions.Encryptor;

   //Set state to Decryptor and set Decryptor metafile
   LEADAnn1.AnnEncryptOptions.Flags:= ANNENCRYPT_TYPE;
   LEADAnn1.AnnFlags:= 0;
   LEADAnn1.AnnEncryptOptions.Encryptor:= TRUE;
   LEADAnn1.AnnSetEncryptOptions (hObject);
   LEADAnn1.AnnSetMetafile( hObject, hMetafile2, ANNMETAFILE_USER, FALSE);

   //Set state to Decryptor and set Decryptor metafile
   LEADAnn1.AnnFlags:= 0;
   LEADAnn1.AnnEncryptOptions.Encryptor:= TRUE;
   LEADAnn1.AnnSetEncryptOptions (hObject);
   LEADAnn1.AnnSetMetafile (hObject, hMetafile2, ANNMETAFILE_USER, FALSE);

   LEADAnn1.AnnEncryptOptions.Encryptor:= bEncryptorOriginal;
   LEADAnn1.AnnFlags:= 0;
   LEADAnn1.AnnSetEncryptOptions (hObject);
end;