#include "l_eprint.h"
HDC EXT_FUNCTION L_EpnCreateSaveDC (pszPrinterName, pDevMode, pSaveOptions, pExtraOptions)
/* printer name */ | |
DEVMODE L_FAR * pDevMode; |
/* pointer to a structure */ |
EPNPRINTERSAVEOPTIONS L_FAR * pSaveOptions; |
/* pointer to a structure */ |
EPNEXTRADCOPTIONS L_FAR * pExtraOptions; |
/* pointer to a structure */ |
Creates a save 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. |
pSaveOptions |
Pointer to an EPNPRINTERSAVEOPTIONS structure that contains file save options to be used when creating a save 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 with the file save options pointed to by the pSaveOptions 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_EpnCreateSaveDC there must be a call to L_EpnDeleteDC to free it.
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_EpnCreateSaveDC 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_EpnCreateEmailDC, L_EpnDeleteDC |
Topics: |
|
|
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 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 CreateSaveDC( HWND hWnd )
{
HDC hDC = NULL;
EPNPRINTERSAVEOPTIONS SaveOptions;
ZeroMemory( & SaveOptions, sizeof( EPNPRINTERSAVEOPTIONS ) );
SaveOptions.uStructSize = sizeof( EPNPRINTERSAVEOPTIONS );
PreparePrinterSaveOptions( & SaveOptions );
DEVMODE * pDevMode = NULL;
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_EpnCreateSaveDC( TEST_PRINTER_NAME, pDevMode, & 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 );
}
}