Article View: be.comp.programming
Article #4933Afdrukken
From: Ivan Van den Bossche
Date: Thu, 19 Jun 2003 18:13
Date: Thu, 19 Jun 2003 18:13
234 lines
7315 bytes
7315 bytes
Hi,
Ik moet door middel van programmatie ervoor kunnen zorgen dat documenten op
verschillende laden moeten gedrukt kunnen worden.
Voorbeeld Ik druk een document vanuit een Windows toepassing af dan moet
deze vb 1 keer gedrukt worden op lade 1 en 4 keer op lade 2.
Ik ben bezig met het aanpassen van de Generic Print Processor die geleverd
is bij de Windows 2000 DDK.
Maar als ik een doc afdruk gebruikmakend van deze print processor krijg ik
een berichtvenster (!!!DocumentProperties!!!) bij de functie
DocumentProperties. Weet er iemand waarom deze in de errorroutine zou
springen????
Kan er mij iemand helpen?
Alvast bedankt
Ivan
Ziehier de aangepaste versie van de file raw.c:
/*++
Copyright (c) 1990-1998 Microsoft Corporation
All Rights Reserved
Abstract:
Routines to facilitate printing of raw jobs.
--*/
#include <windows.h>
#include <winspool.h>
#include <wchar.h>
#include "local.h"
//#include "winprint.h"
BYTE abyFF[1] = { 0xc };
/** Functions found in support.c **/
extern PUCHAR GetPrinterInfo(
IN HANDLE hPrinter,
IN ULONG,
OUT PULONG);
BOOL ConnectPrinter(HANDLE *phtempPrinter, IN LPWSTR pPrinterName, short
dmCopies)
{
PRINTER_DEFAULTS pd;
HANDLE hPrinter;
HWND hDesktop;
PRINTER_INFO_2 *pPi2;
int pi2size;
LONG ret;
BOOL bFlag;
hPrinter = *phtempPrinter;
hDesktop = GetDesktopWindow();
ZeroMemory(&pd, sizeof(PRINTER_DEFAULTS));
pd.pDatatype = NULL;
pd.pDevMode = NULL;
pd.DesiredAccess = PRINTER_ALL_ACCESS;
if(!OpenPrinter(pPrinterName, &hPrinter, &pd))
{
MessageBox(NULL, L"OpenPrinter", L"Error:", MB_SYSTEMMODAL);
return FALSE;
}
SetLastError(0);
bFlag = GetPrinter(hPrinter, 2, 0, 0, &pi2size);
if ((!bFlag) && (GetLastError() != ERROR_INSUFFICIENT_BUFFER) ||
(pi2size == 0))
{
MessageBox(NULL, L"GetPrinter", L"Error:", MB_SYSTEMMODAL);
return FALSE;
}
pPi2 = (PRINTER_INFO_2*) LocalAlloc(LPTR, pi2size);
if(!GetPrinter(hPrinter, 2, (LPBYTE) pPi2, pi2size, &pi2size))
{
MessageBox(NULL, L"GetPrinter2", L"Error:", MB_SYSTEMMODAL);
return FALSE;
}
pPi2->pDevMode->dmCopies = dmCopies;
pPi2->pDevMode->dmFields |= DM_COPIES;
ret = DocumentProperties(hDesktop, hPrinter, pPrinterName, pPi2->pDevMode,
pPi2->pDevMode, DM_IN_BUFFER | DM_OUT_BUFFER);
if (ret != IDOK)
{
MessageBox(NULL, pPrinterName, L"ERROR:", MB_SYSTEMMODAL);
MessageBox(NULL, L"!!!DocumentProperties!!!", L"Error:", MB_SYSTEMMODAL);
return FALSE;
}
if(!SetPrinter(hPrinter, 2, (LPBYTE) pPi2, 0))
{
MessageBox(NULL, L"SetPrinter", L"Error:", MB_SYSTEMMODAL);
return FALSE;
}
*phtempPrinter = hPrinter;
LocalFree((HLOCAL)pPi2);
return TRUE;
}
*/
/*++
*******************************************************************
P r i n t R a w J o b
Routine Description:
Prints out a job with RAW data type.
Arguments:
pData => Print Processor data structure
pPrinterName => name of printer to print on
Return Value:
TRUE if successful
FALSE if failed - GetLastError will return reason
*******************************************************************
--*/
BOOL
PrintRawJob(
IN PPRINTPROCESSORDATA pData,
IN LPWSTR pPrinterName,
IN UINT uDataType)
{
DOC_INFO_1 DocInfo;
DWORD Copies;
DWORD NoRead, NoWritten;
DWORD i;
BOOL rc;
HANDLE hPrinter = NULL;
HANDLE p = NULL;
BYTE pReadBuffer[READ_BUFFER_SIZE];
PRINTER_DEFAULTS pdefaults;
PPRINTER_INFO_2 pPrinterinfo = NULL;
ULONG Error;
DocInfo.pDocName = pData->pDocument; /* Document name */
DocInfo.pOutputFile = pData->pOutputFile; /* Output file */
DocInfo.pDatatype = pData->pDatatype; /* Document data type */
if(pData->hPrinter)
ClosePrinter(pData->hPrinter);
if(!(ConnectPrinter(&pData->hPrinter,pData->pPrinterName, 2)))
{
MessageBox(NULL, L"OpenPrinterHandle1", L"Error:", MB_SYSTEMMODAL);
return FALSE;
}
/** Let the printer know we are starting a new document **/
if (!StartDocPrinter(pData->hPrinter, 1, (LPBYTE)&DocInfo)) {
return FALSE;
}
/** Print the data pData->Copies times **/
Copies = pData->Copies;
while (Copies--) {
/**
Open the printer. If it fails, return. This also sets up the
pointer for the ReadPrinter calls.
**/
//if (!OpenPrinter(pPrinterName, &hPrinter, NULL)) {
if(!(ConnectPrinter(&hPrinter,pData->pPrinterName, 2)))
{
MessageBox(NULL, L"OpenPrinterHandle2", L"Error:",
MB_SYSTEMMODAL);
EndDocPrinter(pData->hPrinter);
return FALSE;
}
/**
Loop, getting data and sending it to the printer. This also
takes care of pausing and cancelling print jobs by checking
the processor's status flags while printing.
**/
while ((rc = ReadPrinter(hPrinter, pReadBuffer, READ_BUFFER_SIZE,
&NoRead)) &&
NoRead) {
/** If the print processor is paused, wait for it to be resumed
**/
if (pData->fsStatus & PRINTPROCESSOR_PAUSED) {
WaitForSingleObject(pData->semPaused, INFINITE);
}
/** If the job has been aborted, don't write anymore **/
if (pData->fsStatus & PRINTPROCESSOR_ABORTED) {
break;
}
/** Write the data to the printer **/
WritePrinter(pData->hPrinter, pReadBuffer, NoRead, &NoWritten);
}
/**
Close the printer - we open/close the printer for each
copy so the data pointer will rewind.
**/
ClosePrinter(hPrinter);
} /* While copies to print */
/** Let the printer know that we are done printing **/
EndDocPrinter(pData->hPrinter);
if(pPrinterinfo)
FreeSplMem((PUCHAR)pPrinterinfo);
return TRUE;
}
Technical Details
Message-ID:
<F3nIa.59604$1u5.4576@afrodite.telenet-ops.be>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!newsfeed2.easynews.com!newsfeed1.easynews.com!easynews.com!easynews!news-out.cwix.com!newsfeed.cwix.com!ossa.telenet-ops.be!afrodite.telenet-ops.be.POSTED!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit X-Google-Thread: 107324,91b17bf1fb332839,start X-Google-Attributes: gid107324,public X-Google-Thread: fcea4,91b17bf1fb332839,start X-Google-Attributes: gidfcea4,public X-Google-ArrivalTime: 2003-06-19 11:14:07 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!newsfeed2.easynews.com!newsfeed1.easynews.com!easynews.com!easynews!news-out.cwix.com!newsfeed.cwix.com!ossa.telenet-ops.be!afrodite.telenet-ops.be.POSTED!not-for-mail From: "Ivan Van den Bossche" <ivan.van.den.bossche@pandora.be> Newsgroups: be.comp.programming,nl.comp.programmeren Subject: Afdrukken Lines: 237 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: <F3nIa.59604$1u5.4576@afrodite.telenet-ops.be> Date: Thu, 19 Jun 2003 18:13:57 GMT NNTP-Posting-Host: 213.119.173.136 X-Complaints-To: abuse@telenet.be X-Trace: afrodite.telenet-ops.be 1056046437 213.119.173.136 (Thu, 19 Jun 2003 20:13:57 MET DST) NNTP-Posting-Date: Thu, 19 Jun 2003 20:13:57 MET DST Organization: Telenet Internet