zoukankan      html  css  js  c++  java
  • delphi 多线程fastreport简单实例

    type

    Tmythread = class(TThread)
    protected
      frxrprttmp: TfrxReport;
      procedure Execute; override;
      procedure testPrintThread();
    public
      constructor Create(frxrprt: TfrxReport);
    end;

    var
    Form2: TForm2;

    implementation

    {$R *.dfm}

    constructor Tmythread.Create(frxrprt: TfrxReport);
    begin
      frxrprttmp := frxrprt;
      inherited Create(False); //false表示线程对象的execute()方法在执行create()方法后立刻自动执行,否则需要在某个地方通过resume后激活该线程
      FreeOnTerminate := False; {这可以让线程执行完毕后随即释放}
    end;

    procedure Tmythread.Execute();
    begin
      Self.Synchronize(testPrintThread);
    end;

    procedure Tmythread.testPrintThread();
    begin
      frxrprttmp.Preview := nil;
      frxrprttmp.PrepareReport;
      frxrprttmp.PrintOptions.ShowDialog := false;
      frxrprttmp.Print;
    end;

    procedure TForm2.cxbtn_designClick(Sender: TObject);
    begin
      frxrprt1.DesignReport();
    end;

    procedure TForm2.cxbtn_openfr3Click(Sender: TObject);
    begin
      if OpenDialog1.Execute then
      begin
        cxTextEdit_1.Text := OpenDialog1.FileName;
      end;
    end;

    procedure TForm2.cxbtn_previewClick(Sender: TObject);
    begin
      frxrprt1.PrepareReport;
      frxrprt1.ShowReport;
    end;

    procedure TForm2.cxbtn_printClick(Sender: TObject);
    var
      i: Integer;
      mythread: Tmythread;
    begin
      for i := 0 to 10 do
      begin
        mythread := Tmythread.Create(frxrprt1);
      end;
    end;

  • 相关阅读:
    java 设计模式 (一)
    多Linux安装
    华北电力大学 研究生学院 笔记
    电力大学 专升本
    19年 考研究生 过程
    netcat-flume-logger
    大神写的K8S 二进制安装笔记
    非常全的Mybatis学习笔记
    Docker-compose部署gitlab
    docker-compose 配合 dockerfile使用
  • 原文地址:https://www.cnblogs.com/yangxuming/p/7153920.html
Copyright © 2011-2022 走看看