您的当前位置:首页正文

C++Builder动态更改自定义打印纸张

2021-07-13 来源:客趣旅游网
C++Builder动态更改自定义打印纸张

void __fastcall TForm1::BitBtn1Click(TObject *Sender) {

char *ADevice, *ADriver, *APort; THandle DeviceMode; PDeviceMode DevMode; int length,width; length=1400;

width=2410; //设定自定义纸张的尺寸单位为0.1毫米 ADevice =new char[100]; ADriver =new char[100]; APort =new char[100]; //获取打印机

Printer()->GetPrinter(ADevice, ADriver, APort,DeviceMode); //获取PDevMode结构

DevMode =(_devicemodeA*) GlobalLock((void *)DeviceMode); //设定可以修改的值

DevMode->dmFields = DevMode->dmFields|DM_PAPERSIZE; DevMode->dmFields = DevMode->dmFields|DM_PAPerlENGTH; DevMode->dmFields = DevMode->dmFields|DM_PAPERWIDTH; //设定要修改的值

DevMode->dmPaperSize=DMPAPER_USER; //设为自定义纸张 DevMode->dmPaperLength=length; DevMode->dmPaperWidth=width; //测试打印

Printer()->BeginDoc();

TextOut(Printer()->Handle, 0, 0, \"-----------------\

Printer()->NewPage();

TextOut(Printer()->Handle, 0, 0, \"++++++++++++++++++\ Printer()->NewPage(); Printer()->EndDoc(); } 1 2

因篇幅问题不能全部显示,请点此查看更多更全内容