Page 1 of 1

Dinamic picture change in FastReport

Posted: Fri Jul 01, 2016 3:04 pm
by Marcelo Via Giglio
Hello,

for the fastreport's users.

We can define copies of the report with dinamic content using CopyName# variable, aditionaly I need to change some picture for every copy, did somebody make some thing like that?

thanks in advance

Marcelo V'ia

Re: Dinamic picture change in FastReport

Posted: Sat Jul 02, 2016 5:15 am
by ShumingWang
1. code :

procedure Picture1OnBeforePrint(Sender: TfrxComponent);
begin
if callhbfunc('file',['.\sub\'+trim(<masterdata."imgid">)+'.jpg']) then
TfrxPictureView(page1.FindObject('picture1')).Picture.LoadFromFile('.\sub\'+trim(<masterdata."imgid">)+'.jpg')
else
TfrxPictureView(page1.FindObject('picture1')).Picture:=nil;
end;
begin
end .


2 .Page -- picture1 ---Event table --- onbforeprint

Re: Dinamic picture change in FastReport

Posted: Sat Jul 02, 2016 2:08 pm
by Marcelo Via Giglio
Hello,

first thanks for your response. Let me be more clear what I need.

We can define reports copy with global variable CopyName#

Code: Select all

frxglobalvariables['copyname0'] := 'PREVIEW';
  frxglobalvariables['copyname1'] := 'COPY1';  
  frxglobalvariables['copyname2'] := 'COPY2';      
  frxglobalvariables['copyname3'] := 'COPY3';
 
then we can view in every copy the value of CopyName# defined for this copy, additional I need to change some picture in the copy,
to do it we can use the OnPrintPage event from [x]harbour code (oFr:SetEventHandler( "Report", "OnPrintPage", {|copia| } ), but I need to change the picture in FR from HB code, then what I need now is how can I change the picture in FR from HB code using LoadFromFile or LoadImageFromHbRes, I think if is possible to call procedures defined in FR from HB I can solve my problem.

Thanks

Marcelo V'ia

Re: Dinamic picture change in FastReport

Posted: Sat Jul 02, 2016 3:32 pm
by Otto
Hello,

do you have DEMO_FWH.prg ?
I think memos and picture shows what you want.
Best regards,
Otto

Image

Re: Dinamic picture change in FastReport

Posted: Sun Jul 03, 2016 1:20 am
by Marcelo Via Giglio
Otto,

thanks for the response, but the mentioned sample link a picture with a field in data source directly, it is not what I need

thanks any way

regards

Marcelo

Re: Dinamic picture change in FastReport

Posted: Mon Jul 04, 2016 12:18 pm
by Mike Serra
Not if it is really what you need , but when I insert an image from a file, what I do is the following:

I have a file in the following path :

c:\image\picture1.jpg

in the report, i put a image control and in the event OnBeforePrint of de Page indicated the following:


Page1OnBeforePrint procedure (Sender : TfrxComponent ) ;
begin
  if length ( < Logo_Empresa > ) < > 0 then
         Picture1.LoadFromFile ( < Logo_Empresa > ) ;
  end;

<Logo_empresa> is a field that happened to the report containing the route , in this case :

C:\image\picture1.jpg

Re: Dinamic picture change in FastReport

Posted: Mon Jul 04, 2016 12:32 pm
by Marcelo Via Giglio
Mike,

thanks for response, but this is not my problem, let me give an explanation:

when we define a FastReport variable CopyName# and we define some numbers of copies, we can get for every copy different content of the CopyName#

Code: Select all

frxglobalvariables['copyname0'] := 'PREVIEW';
  frxglobalvariables['copyname1'] := 'COPY1';  
  frxglobalvariables['copyname2'] := 'COPY2';      
  frxglobalvariables['copyname3'] := 'COPY3';
in this case, in the preview screen we will see "PREVIEW", in the first copy COPY1, in the second one COPY2, etc... additionaly I need to have a different picture for every copy, this is my problem.

Thanks

Marcelo Vía

Re: Dinamic picture change in FastReport

Posted: Fri Aug 12, 2016 8:08 pm
by Horizon
ShumingWang wrote:1. code :

procedure Picture1OnBeforePrint(Sender: TfrxComponent);
begin
if callhbfunc('file',['.\sub\'+trim(<masterdata."imgid">)+'.jpg']) then
TfrxPictureView(page1.FindObject('picture1')).Picture.LoadFromFile('.\sub\'+trim(<masterdata."imgid">)+'.jpg')
else
TfrxPictureView(page1.FindObject('picture1')).Picture:=nil;
end;
begin
end .


2 .Page -- picture1 ---Event table --- onbforeprint
Thank you very much ShumingWang. It worked for me.