一个窗体中调用了两个视屏接口,一个读卡接口,两个电子秤接口,4个预警机接口,这些接口都类似于一个线程
在这个窗体上打印,没有反应;同样打印的方法在一个只调用了一个读卡接口的窗体上很正常。。这种情况可能是什么原因引起的?用fastreport,调用它的loadfromfile方法,加载一个预先设计好的报表文件,再从数据库读取一些宽度高度之类的参数,最后调用它的打印方法。。
到了PrepareReport(预加载报表)时就没有反应了。。代码:
TPrinter中封装了打印相关方法,这个是初始化打印控件constructor TPrinter.Create(Form: TForm;
Oper, OpId, PrintPostion: string; frxReport: TfrxReport);
begin
inherited Create(Form, Oper, OpId);
Self.frxReport := frxReport;
Self.PrintPostion := PrintPostion;
InitPrinter;
end;
procedure TPrinter.InitPrinter;
var
Temp: string;
I: Integer;
Page: TfrxReportPage;
begin
Self.frxReport.Clear;
if Self.frxReport.LoadFromFile(ExtractFileDir(PARAMSTR(0)) + '\configs\' + PrintPostion + '.fr3',true) then
begin
Width := 200;
Height := 100;
Left := 2;
Top := 2;
Times := 0;
Action := 0; //打印方向
Temp := ParamSqlManager.GetValueByName(PrintPostion + 'PrintWidth');
if Temp <> '' then Width := StrtoInt(Temp); Temp := ParamSqlManager.GetValueByName(PrintPostion + 'PrintHeight');
if Temp <> '' then Height := StrtoInt(Temp); Temp := ParamSqlManager.GetValueByName(PrintPostion + 'PrintLeft');
if Temp <> '' then Left := StrtoInt(Temp); Temp := ParamSqlManager.GetValueByName(PrintPostion + 'PrintTop');
if Temp <> '' then Top := StrtoInt(Temp); Temp := ParamSqlManager.GetValueByName(PrintPostion + 'PrintTimes');
if Temp <> '' then Times := StrtoInt(Temp); Temp := ParamSqlManager.GetValueByName(PrintPostion + 'PrintAction');
if Temp <> '' then Action := StrtoInt(Temp); for I := 0 to frxReport.PagesCount - 1 do
begin
if frxReport.Pages[I] is TfrxReportPage then
begin
Page := TfrxReportPage(frxReport.Pages[I]);
Page.PaperWidth := Width;
Page.PaperHeight := Height;
Page.LeftMargin := Left;
Page.TopMargin := Top;
if Action = 0 then
Page.Orientation := poportrait
else
Page.Orientation := poLandscape;
end;
end;
end;
end;这个是打印方法function TPrinter.Print: Boolean;
begin
Self.frxReport.PrintOptions.ShowDialog := False;
Self.frxReport.PrepareReport;
Self.PrintSerial;
Result := Self.frxReport.Print;
end;
调用此单元:
初始化:
Printer := TPrinter.Create(Self, Oper, OpId, 'Cross', frxReport);
打印:
Self.pause;//暂停上面说的线程
if ly_cross_main_unit.Printer.Print then
begin
Self.WeightSQLManager.UpdateWeight(Weight);
Self.WeightSQLManager.UpdateClient(Weight);
Self.WeightSQLManager.UpdatePlan(Weight);
Self.WeightSQLManager.UpdatePlanMoney(Weight);
Self.StartAgain; //恢复线程
end;
在这个窗体上打印,没有反应;同样打印的方法在一个只调用了一个读卡接口的窗体上很正常。。这种情况可能是什么原因引起的?用fastreport,调用它的loadfromfile方法,加载一个预先设计好的报表文件,再从数据库读取一些宽度高度之类的参数,最后调用它的打印方法。。
到了PrepareReport(预加载报表)时就没有反应了。。代码:
TPrinter中封装了打印相关方法,这个是初始化打印控件constructor TPrinter.Create(Form: TForm;
Oper, OpId, PrintPostion: string; frxReport: TfrxReport);
begin
inherited Create(Form, Oper, OpId);
Self.frxReport := frxReport;
Self.PrintPostion := PrintPostion;
InitPrinter;
end;
procedure TPrinter.InitPrinter;
var
Temp: string;
I: Integer;
Page: TfrxReportPage;
begin
Self.frxReport.Clear;
if Self.frxReport.LoadFromFile(ExtractFileDir(PARAMSTR(0)) + '\configs\' + PrintPostion + '.fr3',true) then
begin
Width := 200;
Height := 100;
Left := 2;
Top := 2;
Times := 0;
Action := 0; //打印方向
Temp := ParamSqlManager.GetValueByName(PrintPostion + 'PrintWidth');
if Temp <> '' then Width := StrtoInt(Temp); Temp := ParamSqlManager.GetValueByName(PrintPostion + 'PrintHeight');
if Temp <> '' then Height := StrtoInt(Temp); Temp := ParamSqlManager.GetValueByName(PrintPostion + 'PrintLeft');
if Temp <> '' then Left := StrtoInt(Temp); Temp := ParamSqlManager.GetValueByName(PrintPostion + 'PrintTop');
if Temp <> '' then Top := StrtoInt(Temp); Temp := ParamSqlManager.GetValueByName(PrintPostion + 'PrintTimes');
if Temp <> '' then Times := StrtoInt(Temp); Temp := ParamSqlManager.GetValueByName(PrintPostion + 'PrintAction');
if Temp <> '' then Action := StrtoInt(Temp); for I := 0 to frxReport.PagesCount - 1 do
begin
if frxReport.Pages[I] is TfrxReportPage then
begin
Page := TfrxReportPage(frxReport.Pages[I]);
Page.PaperWidth := Width;
Page.PaperHeight := Height;
Page.LeftMargin := Left;
Page.TopMargin := Top;
if Action = 0 then
Page.Orientation := poportrait
else
Page.Orientation := poLandscape;
end;
end;
end;
end;这个是打印方法function TPrinter.Print: Boolean;
begin
Self.frxReport.PrintOptions.ShowDialog := False;
Self.frxReport.PrepareReport;
Self.PrintSerial;
Result := Self.frxReport.Print;
end;
调用此单元:
初始化:
Printer := TPrinter.Create(Self, Oper, OpId, 'Cross', frxReport);
打印:
Self.pause;//暂停上面说的线程
if ly_cross_main_unit.Printer.Print then
begin
Self.WeightSQLManager.UpdateWeight(Weight);
Self.WeightSQLManager.UpdateClient(Weight);
Self.WeightSQLManager.UpdatePlan(Weight);
Self.WeightSQLManager.UpdatePlanMoney(Weight);
Self.StartAgain; //恢复线程
end;
//fastreport.LoadFromFile('ReportName');//报表设计保存在执行文件目录中
//frReport1.PrepareReport;
//frReport1.PrintPreparedReport('',1,True,frAll);
//frReport1.PrintPreparedReportDlg;