开发学院软件开发C++ C++Builder动态更改自定义打印纸张 阅读

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

 2008-03-08 21:35:39 来源:WEB开发网   
核心提示:void __fastcall TForm1::BitBTn1Click(TObject *Sender){char *ADevice, *ADriver, *APort;THandle DeviceMode;PDeviceMode DevMode;int length,width;length=1400;width=
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->dmFieldsDM_PAPERSIZE;
DevMode->dmFields = DevMode->dmFieldsDM_PAPERLENGTH;
DevMode->dmFields = DevMode->dmFieldsDM_PAPERWIDTH;
//设定要修改的值
DevMode->dmPaperSize=DMPAPER_USER; //设为自定义纸张
DevMode->dmPaperLength=length;
DevMode->dmPaperWidth=width;
//测试打印
Printer()->BeginDoc();
TextOut(Printer()->Handle, 0, 0, "-----------------",17);
Printer()->NewPage();
TextOut(Printer()->Handle, 0, 0, "++++++++++++++++++",18);
Printer()->NewPage();
Printer()->EndDoc();
}



更多文章 更多内容请看C/C++技术专题专题,或

Tags:Builder 动态 更改

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接