1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| LPTSTR printerName = TEXT("Zebra S4M");
HANDLE handle;
if ( !OpenPrinter( printerName, &handle, 0 ) )
{
OutputDebugString( TEXT("Error: OpenPrinter") );
return;
}
int dwDevModeSize;
dwDevModeSize = DocumentProperties(0,handle,printerName,NULL,NULL,0);
if (dwDevModeSize < 0)
{
OutputDebugString(TEXT("Error: DocumentProperties"));
return;
}
DEVMODE* pdevMode = (DEVMODE*)malloc(dwDevModeSize);
if (!pdevMode)
{
return;
}
if ( DocumentProperties(0,handle,printerName,pdevMode,0,DM_OUT_BUFFER) != IDOK )
{
OutputDebugString(TEXT("Error: DocumentProperties"));
return;
}
pdevMode->dmFields |= DM_PAPERSIZE; // dmPaperSize
pdevMode->dmFields |= DM_PAPERLENGTH; // dmPaperLength
pdevMode->dmFields |= DM_PAPERWIDTH; // dmPaperWidth
pdevMode->dmPaperSize = 0;
pdevMode->dmPaperWidth = label->getWidth()*10; // 8" in tenths of a millimeter
pdevMode->dmPaperLength = label->getHeight()*10; // 10" in tenths of a millimeter
if (
DocumentProperties(0,handle,printerName,pdevMode,pdevMode,DM_IN_BUFFER|DM_OUT_BUFFER) != IDOK )
{
OutputDebugString(TEXT("Error: DocumentProperties"));
return;
}
hdc = CreateDC( WDriverName, WDeviceName, WPortName, pdevMode ); |
Partager