c++ builder中用printdialog控件如何设置纸张大小 10
我用printdialog控件打印出来的字体很小,打印出来的文档在页面的左上角,怎么回事啊?程序如下:void__fastcallTForm1::Button1Click...
我用printdialog控件打印出来的字体很小,打印出来的文档在页面的左上角,怎么回事啊?程序如下:void __fastcall TForm1::Button1Click(TObject *Sender)
{
char *ADevice, *ADriver, *APort;
THandle DeviceMode;
PDeviceMode DevMode;
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;//设为自定义纸张
//设定自定义纸张的尺寸单位为0.1毫米
DevMode->dmPaperLength=1500;
DevMode->dmPaperWidth=1800;
PrintDialog1->Options.Clear();
PrintDialog1->Options << poPageNums << poSelection;
PrintDialog1->FromPage = 1;
PrintDialog1->MinPage = 1;
PrintDialog1->ToPage = PageControl1->PageCount;
PrintDialog1->MaxPage = PageControl1->PageCount;
if (PrintDialog1->Execute())
{
int Start, Stop;
// determine the range the user wants to print
switch (PrintDialog1->PrintRange)
{
case prSelection:
Start = PageControl1->ActivePage->PageIndex;
Stop = Start;
break;
case prPageNums:
Start = PrintDialog1->FromPage - 1;
Stop = PrintDialog1->ToPage - 1;
break;
default: // prAllPages
Start = PrintDialog1->MinPage - 1;
Stop = PrintDialog1->MaxPage - 1;
break;
}
// now, print the pages
Printer()->BeginDoc();
for (int i = Start; i <= Stop; i++)
{
PageControl1->Pages[i]->PaintTo(Printer()->Handle, 10, 10);
if (i != Stop)
Printer()->NewPage();
}
Printer()->EndDoc();
}
}
//--------------------------------------------------------------------------- 展开
{
char *ADevice, *ADriver, *APort;
THandle DeviceMode;
PDeviceMode DevMode;
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;//设为自定义纸张
//设定自定义纸张的尺寸单位为0.1毫米
DevMode->dmPaperLength=1500;
DevMode->dmPaperWidth=1800;
PrintDialog1->Options.Clear();
PrintDialog1->Options << poPageNums << poSelection;
PrintDialog1->FromPage = 1;
PrintDialog1->MinPage = 1;
PrintDialog1->ToPage = PageControl1->PageCount;
PrintDialog1->MaxPage = PageControl1->PageCount;
if (PrintDialog1->Execute())
{
int Start, Stop;
// determine the range the user wants to print
switch (PrintDialog1->PrintRange)
{
case prSelection:
Start = PageControl1->ActivePage->PageIndex;
Stop = Start;
break;
case prPageNums:
Start = PrintDialog1->FromPage - 1;
Stop = PrintDialog1->ToPage - 1;
break;
default: // prAllPages
Start = PrintDialog1->MinPage - 1;
Stop = PrintDialog1->MaxPage - 1;
break;
}
// now, print the pages
Printer()->BeginDoc();
for (int i = Start; i <= Stop; i++)
{
PageControl1->Pages[i]->PaintTo(Printer()->Handle, 10, 10);
if (i != Stop)
Printer()->NewPage();
}
Printer()->EndDoc();
}
}
//--------------------------------------------------------------------------- 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询