更改的内容
================================================================================
frxPreview.pas ?V3.07...
--------------------------------------------------------------------------------
procedure TfrxPreviewForm.PrintBClick(Sender: TObject);
var
Overlay: TfrxComponent;
//Add by Flying,2004.10.10
begin
if not frxPrinters.HasPhysicalPrinters then
frxErrorMsg(frxResources.Get('clNoPrinters'))
else
//FPreview.Print;
//Delete by Flying,2004.10.10
// Add by Flying,2004.10.10
// ---------------------- From -------------------
begin
Overlay := Report.FindObject('Overlay');
if Overlay=nil then
FPreview.Print else
begin
Overlay.Visible := False;
Report.PrepareReport;
FPreview.Print;
end
end;
// ---------------------- To ---------------------
end;
一、在同一个FastReport文件中就能实现:
把只需预览时显示不需要打印的对象的Tag属性定义为一个负数,如-1,然后用下面的代码替换原程序中的相应部分就可以了:
function notprint(frReport1:tfrReport):boolean;
//处理不需打印的对象
var
i,j:integer;
begin
for j:=0 to frreport1.Pages.Count-1do
for i:=0 to frReport1.Pages[j].Objects.count-1do
if strtointdef(TfrView(frReport1.Pages[j].Objects).tag,0)<0 then
TfrView(frReport1.Pages[j].Objects).Visible:=false;
end;
procedure TForm1.Button1Click(Sender: TObject);
//打印
begin
frReport1.LoadFromFile('c:/1.frf');
notprint(frReport1);
frReport1.PrepareReport;
frReport1.PrintPreparedReport('',1,True,frAll);
end;
procedure TForm1.Button2Click(Sender: TObject);
//预览
begin
frReport1.LoadFromFile('c:/1.frf');
frReport1.ShowReport;
end;
procedure TForm1.btn1Click(Sender: TObject);
//预览
begin
frReport1.LoadFromFile('c:/1.frf');
frReport1.ShowReport;
end;
procedure TForm1.btn2Click(Sender: TObject);
//打印
var
i, j : integer;
begin
frReport1.LoadFromFile('c:/1.frf');
for j := 0 to frReport1.Pages.Count - 1do
for i := 0 to frReport1.Pages[j].Objects.Count - 1do
begin
if TfrView(frReport1.Pages[j].Objects).classname = 'TfrMemoView' then
TfrView(frReport1.Pages[j].Objects).FrameTyp := 0;
//边框不打印
if TfrView(frReport1.Pages[j].Objects).classname = 'TfrLineView' then
TfrView(frReport1.Pages[j].Objects).Visible := false;
// 划线不打印
end;
frReport1.PrepareReport;
frReport1.PrintPreparedReport('', 1, True, frAll);
end;