获取打印页边距

  • 主题发起人 主题发起人 import
  • 开始时间 开始时间
I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
获取打印页边距
uses Printers;
procedure TForm1.Button1Click(Sender: TObject);
var
EscapeCode : integer;
Margin : TPoint;
begin
if PrintDialog1.Execute then begin
{$IFDEF WIN32}
Margin.x :=GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX);
Margin.y :=GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY);
{$ELSE}
EscapeCode := GETPRINTINGOFFSET;
if Escape(Printer.Handle,
QUERYESCSUPPORT,
sizeof(EscapeCode),
@EscapeCode,
nil) <> 0 then
if Escape(Printer.Handle,
GETPRINTINGOFFSET,
0,
nil,
@Margin) < 1 then begin
EscapeCode := GETPHYSPAGESIZE;
if Escape(Printer.Handle,
QUERYESCSUPPORT,
sizeof(EscapeCode),
@EscapeCode,
nil) <> 0 then
if Escape(Printer.Handle,
GETPHYSPAGESIZE,
0,
nil,
@Margin) > 0 then begin
Margin.x := (Margin.x -
GetDeviceCaps(Printer.Handle, HorzRes)) div 2;
Margin.y := (Margin.y -
GetDeviceCaps(Printer.Handle, VertRes)) div 2;
end else begin
Margin.x := 0;
Margin.y := 0;
end;
end;
{$ENDIF}
Memo1.Lines.Add(IntToStr(Margin.x));
Memo1.Lines.Add(IntToStr(Margin.y));
end;
end;
呵呵,我也是Copy下来的,借花献佛吧,你自己看.
 

Similar threads

S
回复
0
查看
585
SUNSTONE的Delphi笔记
S
S
回复
0
查看
681
SUNSTONE的Delphi笔记
S
S
回复
0
查看
694
SUNSTONE的Delphi笔记
S
S
回复
0
查看
689
SUNSTONE的Delphi笔记
S
后退
顶部