royal1442 你好!我使用了你的给出的上面的代码和我下面的代码,打印出来有走纸到整个纸张走完,不能按自定义的纸张走纸。你看看是哪里有问题,请帮我修改,以下我的代码:
procedure Tshowprint1Form.toprint(Sender: TObject);
var x,y,i,temhi,temwd:integer;
strect:Trect;
ADevice,Adriver,APort:string;
PDevice,Pdriver,PPort:array[0..255] of char;
hDMODE:THandle;
PDMODE
Devicemode;
begin
//打印
SetPaperHeight(90);
SetPaperWidth(240);
temhi:=image1.Picture.Height ;
temwd:=image1.Picture.width ;
while (temhi<printer.PageHeight) and (temwd<printer.pagewidth)do
begin
temhi:=temhi+temhi;
temwd:=temwd+temwd;
end;
with strectdo
begin
left:=1;
top:=1;
right:=left+temwd;
bottom:=top+temhi;
end;
with printerdo
begin
begin
doc;
canvas.stretchDraw(strect,image1.picture.graphic);
enddoc;
end;
end;
procedure Tshowprint1Form.tofile(Sender: TObject);
var image:Timage;
bitMap:Tbitmap;
begin
Image:=TImage.Create(Self);
BitMap:=TBitMap.Create ;
bitMap.Width :=240;
bitMap.Height:=90;
BitBlt(BitMap.Canvas.Handle,0,0,240,90,GetDC(Handle),
0,0,SRCCOPY);
image.Picture.Graphic:=BitMap;
bitMap.Free;
Image.Free ;
end;