////////////////////////////////////////////////////////////////////////////
//Wuhan Explore Computer Studio//
//http://tansuo.51.net//
///////////////////////////////////////////////////////////////////////////
//Add to customize the paper specification
//PaperName: Custom paper name
//PaperWidth: The width of the paper, in units of 0.1mm
//PaperLength: The height of the paper, in units of 0.1mm
PRocedureTDM.AddCustomPaper(constPaperName:string;PaperWidth,PaperLength:integer);
var
PrintDevice, PrintDriver, PrintPort:array[0..255] ofChar;
hDMode:THandle;
hPrinter:THandle;
FormInfo:TFormInfo1;
Begin
Printer.GetPrinter(PrintDevice,PrintDriver,PrintPort,hDMode);
OpenPrinter(PrintDevice,hPrinter,nil);
ifhPrinter=0then
raiseException.Create('Joining printer failed!');
withFormInfodo
Begin
Flags:=FORM_USER;
pName:=PChar(PaperName);
Size.cx:=PaperWidth*100;
Size.cy:=PaperLength*100;
ImageableArea.Left:=0;
ImageableArea.Top:=0;
ImageableArea.Right:=PaperWidth*100;
ImageableArea.Bottom:=PaperLength*100;
end;
//Modify the paper type, if not, add new ones
ifnotSetForm(hPrinter,PChar(PaperName),1,@FormInfo)then
AddForm(hPrinter,1,@FormInfo);
ClosePrinter(hPrinter);
end;
//Delete custom specification paper
//PaperName: Custom paper name
procedureTDM.DeleteCustomPaper(constPaperName:string);
var
PrintDevice, PrintDriver, PrintPort:array[0..255] ofChar;
hDMode:THandle;
hPrinter:THandle;
Begin
Printer.GetPrinter(PrintDevice,PrintDriver,PrintPort,hDMode);
OpenPrinter(PrintDevice,hPrinter,nil);
ifhPrinter=0then
raiseException.Create('Joining printer failed!');
DeleteForm(hPrinter,PChar(PaperName));
ClosePrinter(hPrinter);
end;