首页 > 学院 > 开发设计 > 正文

CB编程中动态更改自定义打印纸张

2019-11-17 05:43:46
字体:
来源:转载
供稿:网友

  因网上只有Delphi例子本人在用CB编写时发现有一些例子不能用,
所以一生气就索性查了查资料自己写了,怕网友们在用编程时也遇见此类情况,
就马上传了上来。

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();
}

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表