#include "l_eprint.h"
L_INT pEXT_CALLBACK YourFunction (pszPrinterName, hMem, uSize, pData)
/* printer name */ | |
HGLOBAL hMem; |
/* handle to a memory block */ |
L_UINT uSize; |
/* size of memory block */ |
/* pointer to additional parameters */ |
Callback function fired for every page printed using the LEADTOOLS ePrint.
Parameter |
Description |
pszPrinterName |
Character string that contains the name of the ePrint printer. |
hMem |
Handle to the block of memory that contains an EMF data file. |
uSize |
The size of the data file in memory pointed to by the hMem parameter. |
pData |
A void pointer that you can use to access a variable or structure that contains data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function. This is the same pointer passed to the L_EpnRegisterCallback function in the pCallbackInfo parameter. |
|
Keep in mind that this is a void pointer, which must be cast to the appropriate data type within your callback function. |
Comments
The contents of each printed page will be received in the EMF data file pointed to by the hMem parameter. When the hMem is no longer needed, it should be freed by calling the GlobalFree function.
Returns
SUCCESS |
This function does not take into consideration the returned values. |
Required DLLs and Libraries
LPKRN For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
See Also
Functions: |
L_EpnInstallOEMPrinter, L_EpnRegisterCallback, L_EpnUnRegisterCallback, RASRGSPROC |
Topics: |
|
|
Example
L_INT EXT_CALLBACK EMFStatus( L_CHAR * pszPrinter,
HGLOBAL hMem,
L_UINT uSize,
L_VOID * pData )
{
L_INT nRet = SUCCESS;
HANDLE hFile = INVALID_HANDLE_VALUE;
DWORD uSizeWritten = 0;
L_UCHAR * pEmfFile = (L_UCHAR*) GlobalLock( hMem );
if( pEmfFile )
{
hFile = CreateFile ("C:\\Test.emf", GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL);
if (hFile != INVALID_HANDLE_VALUE)
{
WriteFile (hFile, pEmfFile, uSize, &uSizeWritten, NULL);
CloseHandle (hFile);
}
GlobalUnlock( hMem );
}
// Do not forget freeing the mem.
GlobalFree( hMem );
return nRet;
}
L_INT EXT_CALLBACK RASStatus( L_CHAR * pszPrinter,
HGLOBAL hMem,
L_UINT uSize,
L_UINT uType,
L_VOID * pData )
{
BITMAPINFO * pBitmAPInfo = (BITMAPINFO*) GlobalLock( hMem );
L_INT nInfoSize = 0;
L_INT nColorData = 0;
if( pBitmAPInfo->bmiHeader.biBitCount <= 8 )
{
nColorData = 1 << pBitmAPInfo->bmiHeader.biBitCount;
}
// get the required size
nInfoSize = sizeof( BITMAPINFOHEADER ) + ( nColorData * sizeof( RGBQUAD ) );
unsigned char * pTBits = NULL;
pTBits = (unsigned char *) pBitmAPInfo + nInfoSize;
StretchDIBits( (HDC) pData,
0,
0,
pBitmAPInfo->bmiHeader.biWidth,
pBitmAPInfo->bmiHeader.biHeight,
0,
0,
pBitmAPInfo->bmiHeader.biWidth,
pBitmAPInfo->bmiHeader.biHeight,
pTBits,
pBitmAPInfo,
DIB_RGB_COLORS,
SRCCOPY
);
// Do not forget freeing the mem.
GlobalFree( hMem );
return 0;
}
EPNCALLBACKIDINFO IMGIDInfo;
/* Note that you should call CoInitialize( NULL ) before calling the L_EpnRegisterCallback */
L_VOID RegisterIMGCallback( HDC hDC )
{
EPNIMGCALLBACKINFO IMG;
ZeroMemory( & IMG, sizeof( EPNIMGCALLBACKINFO ) );
IMG.uStructSize = sizeof( EPNIMGCALLBACKINFO );
IMG.pData = hDC;
IMG.pfnEMFCallback = & EMFStatus;
IMG.pfnRasCallback = & RASStatus;
ZeroMemory( & IMGIDInfo, sizeof( EPNCALLBACKIDINFO ) );
IMGIDInfo.uStructSize = sizeof( EPNCALLBACKIDINFO );
L_EpnRegisterCallback ( "Test Printer Name", EPRINT_CALLBACKS_IMG, & IMG, & IMGIDInfo );
}
/* Note that you should call CoUninitialize( ) after calling the L_EpnUnRegisterCallback if this is the last registered callback. */
L_VOID UnRegImgCallback( )
{
L_EpnUnRegisterCallback ( & IMGIDInfo );
}