void __fastcall TForm1::BitBTn1Click(TObject *Sender)
{
char *ADevice, *ADriver, *APort;
THandle DeviceMode;
PDeviceMode DevMode;
int length,width;
length=1400;
width=2410; //設定自定義紙張的尺寸單位為0.1毫米
<!-- frame contents -->
<!-- /frame contents -->
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++技術專題專題,或