怎么获得打印页边据 打印页边据 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 得到页边距:Margin.x :=GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX);{页边距X}Margin.y :=GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY);{页边距y} unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; PrintDialog1: TPrintDialog; Memo1: TMemo;// procedure FormCreate(Sender: TObject); // procedure FormClick(Sender: TObject); procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM}//获取打印页边距uses Printers;procedure TForm1.Button1Click(Sender: TObject);varEscapeCode : integer;Margin : TPoint;beginif 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 thenif Escape(Printer.Handle,GETPRINTINGOFFSET,0,nil,@Margin) < 1 thenbeginEscapeCode := GETPHYSPAGESIZE;if Escape(Printer.Handle,QUERYESCSUPPORT,sizeof(EscapeCode),@EscapeCode,nil) <> 0 thenif Escape(Printer.Handle,GETPHYSPAGESIZE,0,nil,@Margin) > 0 thenbeginMargin.x := (Margin.x -GetDeviceCaps(Printer.Handle, HorzRes)) div 2;Margin.y := (Margin.y -GetDeviceCaps(Printer.Handle, VertRes)) div 2;end else beginMargin.x := 0;Margin.y := 0;end;end;{$ENDIF}Memo1.Lines.Add(IntToStr(Margin.x));Memo1.Lines.Add(IntToStr(Margin.y));end;end;end. 一个简单的圆和切线问题!!急~~~~~~~~~高分(100) 求delphi分布式开发的电子书! 寫一個數據庫表内容簡轉繁的函數!高手指點 工作了2个月,突然感到迷茫了~ 郁闷,为什么在SQL SERVER 中定义为DataTime类型字段的表在Delphi中更新记录时出错 大家好!请问installshied是通用的还是有一种专给delphi用的! 对word文档内容的读取问题 综合统计的方案 怎样获取ShellTreeView1的文件夹名(含路径)? 你走了~就走了~不要让“我们”伤心~ 用Delphi如何得到物理内存的大小? 请解释一下这句的意思
Margin.x :=GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX);{页边距X}
Margin.y :=GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY);{页边距y}
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
PrintDialog1: TPrintDialog;
Memo1: TMemo;
// procedure FormCreate(Sender: TObject);
// procedure FormClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}//获取打印页边距
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;end.