//---------打印设置-------------
unit RepSetupUnit;interfaceuses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, Buttons,printers, Spin;type
  TRepSetupForm = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    TitleEdit: TEdit;
    Label2: TLabel;
    UpEdit: TEdit;
    Label3: TLabel;
    DownEdit: TEdit;
    Label4: TLabel;
    LeftEdit: TEdit;
    Label5: TLabel;
    RightEdit: TEdit;
    Label6: TLabel;
    FXComboBox: TComboBox;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Label7: TLabel;
    WidthEdit: TEdit;
    Label8: TLabel;
    LengthEdit: TEdit;
    Label9: TLabel;
    Label10: TLabel;
    PJPRNFontDialog: TFontDialog;
    DFontButton: TButton;
    DetailHightSpinEdit: TSpinEdit;
    Label11: TLabel;
    procedure BitBtn1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure DFontButtonClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    TopMargin,BottomMargin,LeftMargin,RightMargin:integer;
    Orientation: TPrinterOrientation;
    PaperWidth,PaperLength:Integer;
    Title :String;
    FontName:String;
    FontSize,DetailHight:Integer;
  end;var
  RepSetupForm: TRepSetupForm;implementationuses FindInOutUnit;{$R *.DFM}procedure TRepSetupForm.BitBtn1Click(Sender: TObject);
begin
    TopMargin := StrToInt(UpEdit.Text);
    BottomMargin:= StrToInt(DownEdit.Text);
    LeftMargin:= StrToInt(LeftEdit.Text);
    RightMargin:= StrToInt(RightEdit.Text);
    if FXComboBox.Text='poPortrait' then
      Orientation:=poPortrait
    else
      Orientation:=poLandscape;
    Title :=TitleEdit.Text;
    PaperWidth := StrToInt(WidthEdit.Text);  //纸宽
    PaperLength:=StrToInt(LengthEdit.Text);  //纸长
    FontName := DFontButton.Font.Name;
    FontSize := DFontButton.Font.Size;
    DetailHight := DetailHightSpinEdit.Value;
end;procedure TRepSetupForm.FormCreate(Sender: TObject);
begin
    TopMargin := 10;
    BottomMargin:= 10;
    LeftMargin:= 10;
    RightMargin:= 10;
    Orientation:=poPortrait;
    Title :='标题';
    PaperWidth := 210;
    PaperLength:=297;
    FontName := '宋体';
    FontSize := 12 ;
end;procedure TRepSetupForm.DFontButtonClick(Sender: TObject);
begin
  If Not (PJPRNFontDialog.Execute) Then Exit;;
  if ActiveControl is TButton then
      with ActiveControl as TButton do
        Begin
           Font.Assign(PJPRNFontDialog.Font);
         End
       Else
        Beep;
end;end.
//------打印------------
try
    RepTemp.ActiveDataSource.DataSet := Query;
   //  RepTemp.QuickRep1.Page.PaperSize:=A4;
    RepTemp.QuickRep1.Page.Length:=RepSetupForm.PaperLength;
    RepTemp.QuickRep1.Page.Width:=RepSetupForm.PaperWidth;
    RepTemp.QuickRep1.Page.BottomMargin:=RepSetupForm.BottomMargin;
    RepTemp.QuickRep1.Page.TopMargin:=RepSetupForm.TopMargin;
    RepTemp.QuickRep1.Page.LeftMargin:=RepSetupForm.LeftMargin;
    RepTemp.QuickRep1.Page.RightMargin:=RepSetupForm.RightMargin;
    RepTemp.QuickRep1.Page.Orientation:=RepSetupForm.Orientation;
    RepTemp.TitleLabel.Caption:=RepSetupForm.Title;
    RepTemp.TmpFontLabel.Font.Name := RepSetupForm.FontName ;
    RepTemp.TmpFontLabel.Font.Size := RepSetupForm.FontSize ;
    RepTemp.DetailBand1.Height := RepSetupForm.DetailHight;
    RepTemp.CreateRep;
    RepTemp.QuickRep1.Preview;
  finally
    RepTemp.free;
  end;

解决方案 »

  1.   

    to: niat97222(Freeman) 
    QRP中定义了纸张A4还能定义大小吗?
    另外,需要连续走纸,精确定位
      

  2.   

    Win2000上,不能用自定义报表的,怎么办?发现所有打印机都不没有自定义这一选项,所认,我们的Quickrep做的报表都不能打印自定义纸张!
    哪位有办法搞定?
      

  3.   

    Quickrep打印自定义纸张用到RTTI可以实现,在2000年做过的!还要再看一下原码!
      

  4.   

    : bluedreaming(蓝色海岸)   RTTI是什么,怎用???
      

  5.   

    用  PrinterSetupDialog1.Execute ;得到  printer.PageWidth保存打印时候读取报表自定义大小
      

  6.   


        RepTemp.QuickRep1.Page.Length:=RepSetupForm.PaperLength;
        RepTemp.QuickRep1.Page.Width:=RepSetupForm.PaperWidth;
        这两句话是定义纸张大小的
    另外,在2000下,设置打印纸张大小应该是
    开始--》设置---》打印机,然后在打印机窗口菜单的服务器属性里可以定义纸张的大小,和98下自定义纸张的方法有点不同