有写过打印预览和打印设置的朋友进来看下,100分求问题解决.
有写过打印预览和打印设置的朋友进来看下,100分求问题解决.
我按照msdn的DocumentProperties上面的步骤,获得了当前的DEVMODE,然后把devmode的dmFormName和其他几个属性修改了,然后用
DocumentProperties把DEVMODE传回去,最后用resetDC把打印机更新,但是为什么怎么都不能对纸张进行,设置呢?
做过的朋友能给点帮助么?主要看我代码流程错在哪里了
BYTE * aDev; //working DevMode
DEVMODE DevIn;
HANDLE hPrinter;
Char *PrinterName=Printer()->Printers->Strings[1].c_str(); //current printerName
OpenPrinter(PrinterName,&hPrinter,NULL);
long dwNeeded=DocumentProperties(NULL,hPrinter,
PrinterName,0,0,0);//get the size of Buffer
aDev=new BYTE[dwNeeded];
DocumentProperties(NULL,hPrinter,
PrinterName,(DEVMODE*)aDev,0,DM_OUT_BUFFER); //output Buffer
memcpy(&DevIn,aDev,sizeof(DevIn));
DevIn.dmPaperSize=DMPAPER_LETTER;
DevIn.dmFields = DevIn.dmFields |DM_PAPERSIZE;
memcpy(aDev,&DevIn,sizeof(DevIn));
DocumentProperties(NULL,hPrinter,PrinterName,(DEVMODE*)aDev,(DEVMODE*)aDev,DM_OUT_BUFFER|DM_IN_BUFFER);//Input BUffer
HDC hdc=CreateDC(NULL,PrinterName,NULL,NULL);
ResetDC( hdc,(DEVMODE*)aDev );// DC information