L_EpnCreateEmailDC

#include "l_eprint.h"

HDC EXT_FUNCTION L_EpnCreateEmailDC (pszPrinterName, pDevMode, pMailMessageInfo, pSaveOptions, pExtraOptions)

L_CHAR L_FAR * pszPrinterName;

/* printer name */

DEVMODE L_FAR * pDevMode;

/* pointer to a structure */

EPNMAILMESSAGEINFO L_FAR * pMailMessageInfo;

/* pointer to a structure */

EPNPRINTERSAVEOPTIONS L_FAR * pSaveOptions;

/* pointer to a structure */

EPNEXTRADCOPTIONS L_FAR * pExtraOptions;

/* pointer to a structure */

Creates an e-mail redirection device context (DC).

Parameter

Description

pszPrinterName

Character string that contains the name of the ePrint printer.

pDevMode

Pointer to a DEVMODE structure that contains specific initialization data of an ePrint printer device driver.

pMailMessageInfo

Pointer to an EPNMAILMESSAGEINFO structure that contains mail message options to be used when creating the e-mail device context.

pSaveOptions

Pointer to an EPNPRINTERSAVEOPTIONS structure that contains file save options to be used when creating the e-mail device context.

pExtraOptions

Pointer to an EPNEXTRADCOPTIONS structure that contains additional information when using an OEM printer indirectly when the OEM printer is locked.

 

The value of this parameter will be ignored if the OEM printer is unlocked and you should pass NULL.

Returns

>0

Function was successful. The return value is the HDC.

NULL

An error occurred. To get extended error information, call the Windows C DLL GetLastError function.

Comments

Support for Basic functionality must be unlocked by calling the L_EpnUnlockSupport function before using this function.

The created DC can be used as an ordinary printer DC. Each GDI command executed for this DC will be saved as a file using the file save options pointed to by the pSaveOptions parameter. These files will be attached to an email message and sent to the mail recipient(s) using the options pointed to by pMailMessageInfo parameter.

Before using the created DC, the user should call the StartDoc and StartPage Windows C DLL functions. After using the created DC the user should call the EndPage and EndDoc Windows C DLL functions.

When the created DC is no longer needed, it should be deleted by calling L_EpnDeleteDC. For every DC created using L_EpnCreateEmailDC there must be a call to L_EpnDeleteDC to free it.

If the mail configuration settings for a specific printer were not set, then the user should set these using the L_EpnSetPrinterEmailConfiguration function before calling the L_EpnCreateEmailDC function.

For OEM Printers:

If the OEM printer is locked, then the user can use it indirectly by using this function.

To use the locked OEM printer indirectly, pass a valid data to the pExtraOptions parameter. The pExtraOptions parameter is a pointer to an EPNEXTRADCOPTIONS structure. Please note that the pszPassword member of the EPNEXTRADCOPTIONS structure must be filled by the administration password that was used when the OEM printer was installed by calling the L_EpnInstallOEMPrinter function.

If the printer is locked and either NULL or an invalid password is supplied in pExtraOptions, the L_EpnCreateEmailDC function will fail and return NULL.

For more information, refer to Locking and Unlocking the OEM ePrint Printer.

Required DLLs and Libraries

LPKRN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to ePrint Files.

See Also

Functions:

L_EpnLockOEMPrinter, L_EpnUnlockOEMPrinter, L_EpnInstallOEMPrinter, L_EpnUninstallOEMPrinter, L_EpnCreateRedirectionDC, L_EpnCreateSaveDC, L_EpnDeleteDC

Topics:

ePrint: Printing indirectly to OEM Printers

 

Redirecting to Send an Email

Example

L_VOID PreparePrinterSaveOptions( EPNPRINTERSAVEOPTIONS * pSaveOptions ) 
{
   ZeroMemory( pSaveOptions, sizeof( EPNPRINTERSAVEOPTIONS ) ); 
   pSaveOptions->uStructSize = sizeof( EPNPRINTERSAVEOPTIONS ); 
   
   pSaveOptions->SaveOptions.uStructSize = sizeof( EPNSAVEOPTIONS ); 
   
   lstrcpy( pSaveOptions->SaveOptions.szFileName, _T( "c:\\Untitled.cmp" ) ); 
   pSaveOptions->SaveOptions.nFormat = FILE_CMP; // ( CMP ) 
   
   pSaveOptions->SaveOptions.DocumentType = DLG_FT_SAVE_TYPE_RASTER; 
   pSaveOptions->SaveOptions.RasterOptions.uStructSize = sizeof ( EPNRASTEROPTIONS ); 
   pSaveOptions->SaveOptions.RasterOptions.nBitsPerPixel = 24; 
   pSaveOptions->SaveOptions.RasterOptions.nQFactor = 100; 
   pSaveOptions->SaveOptions.RasterOptions.nStampBits = 24; 
   pSaveOptions->SaveOptions.RasterOptions.nStampWidth = 128; 
   pSaveOptions->SaveOptions.RasterOptions.nStampHeight = 128; 
   pSaveOptions->SaveOptions.RasterOptions.bMultiPageFile = FALSE; 
   
   L_EpnGetDefaultNamingOptions ( & pSaveOptions->NamingOptions, sizeof( EPNNAMINGOPTIONS ) ); 
}
L_VOID PrepareMailMessage( EPNMAILMESSAGEINFO * pMsg ) 
{
   pMsg->uStructSize = sizeof( EPNMAILMESSAGEINFO ); 
   pMsg->bUseMail = TRUE; 
   pMsg->pszTo = "someone@somedomain.com";
   pMsg->pszCc = "another@anotherdomain.com";
   pMsg->pszBcc = "someonespecial@anotherdomain.com";
   pMsg->pszSubject = "Attached Images";
   pMsg->pszBody = "Hello, attached are the images."; 
   /* Set this to zero  */
   pMsg->uEmailSaveOptionsIndex = 0; 
}

L_VOID PlayGDICommands( HDC hDC, HWND hWnd ) 
{
   // Add here any GDI operations you want
   
   RECT rct; 
   GetClientRect( hWnd, & rct ); 
   BeginPath( hDC ); 
   TextOut( hDC, rct.left, rct.top, "Sample Drawing", 2 ); 
   EndPath( hDC ); 
   SelectClipPath( hDC, RGN_AND ); 
   FillRect( hDC, & rct, (HBRUSH) GetStockObject( GRAY_BRUSH ) ); 
}

#define TEST_PRINTER_NAME "Test Printer Name"

L_VOID CreateEMailDC( HWND hWnd ) 
{
   HDC hDC = NULL; 
   DEVMODE * pDevMode = NULL; 
   EPNMAILMESSAGEINFO MailMsg; 
   ZeroMemory( & MailMsg, sizeof( EPNMAILMESSAGEINFO ) ); 
   PrepareMailMessage( & MailMsg ); 
   EPNPRINTERSAVEOPTIONS SaveOptions; 
   ZeroMemory( & SaveOptions, sizeof( EPNPRINTERSAVEOPTIONS ) ); 
   PreparePrinterSaveOptions( & SaveOptions ); 
   
   EPNEXTRADCOPTIONS Extra; 
   ZeroMemory( & Extra, sizeof( EPNEXTRADCOPTIONS ) ); 
   Extra.uStructSize = sizeof( EPNEXTRADCOPTIONS ); 
   /* This should be the same as the password passed in the EPNOEMPRINTERINFO structure to the L_EpnInstallOEMPrinter */
   Extra.pszPassword = "Test Password";
   Extra.uReserved = 0; 
   // Pass NULL instead of the Extra parameter if the printer hadn't been locked
   hDC = L_EpnCreateEmailDC( TEST_PRINTER_NAME, pDevMode, & MailMsg, & SaveOptions, & Extra ); 
   if( hDC )  
   {
      DOCINFO DocInfo; 
      ZeroMemory( & DocInfo, sizeof( DOCINFO ) ); 
      DocInfo.cbSize = sizeof( DOCINFO ); 
      DocInfo.lpszDocName = "Test File";
      L_INT nRet = 0; 
      // Start Doc
      if(StartDoc( hDC, & DocInfo ) > 0 ) 
      {
         // Start Page
         if( StartPage( hDC ) ) 
         {
            // Do what you want with the HDC
            PlayGDICommands( hDC, hWnd ); 
            // End Page
            EndPage( hDC); 
         }
         // End Doc
         EndDoc( hDC ); 
      }
      // Delete DC
      L_EpnDeleteDC ( hDC ); 
   }
}