Dinamic picture change in FastReport

Post Reply
Marcelo Via Giglio
Posts: 1033
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Dinamic picture change in FastReport

Post 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
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Re: Dinamic picture change in FastReport

Post 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
Marcelo Via Giglio
Posts: 1033
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: Dinamic picture change in FastReport

Post 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
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: Dinamic picture change in FastReport

Post by Otto »

Hello,

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

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
Marcelo Via Giglio
Posts: 1033
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: Dinamic picture change in FastReport

Post 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
Mike Serra
Posts: 287
Joined: Fri Apr 14, 2006 5:52 pm
Location: Córdoba (España)

Re: Dinamic picture change in FastReport

Post 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
Marcelo Via Giglio
Posts: 1033
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: Dinamic picture change in FastReport

Post 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
Horizon
Posts: 997
Joined: Fri May 23, 2008 1:33 pm

Re: Dinamic picture change in FastReport

Post 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.
Regards,

Hakan ONEMLI

Harbour & VS 2019 & FWH 20.12
Post Reply