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;

 

相关文章:

  • 2021-10-19
  • 2022-12-23
  • 2021-11-18
  • 2021-12-06
  • 2022-12-23
猜你喜欢
  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2021-07-07
  • 2022-12-23
相关资源
相似解决方案