Dinamic picture change in FastReport

Dinamic picture change in FastReport

Postby Marcelo Via Giglio » Fri Jul 01, 2016 3:04 pm

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

Re: Dinamic picture change in FastReport

Postby ShumingWang » Sat Jul 02, 2016 5:15 am

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
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Re: Dinamic picture change in FastReport

Postby Marcelo Via Giglio » Sat Jul 02, 2016 2:08 pm

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

Re: Dinamic picture change in FastReport

Postby Otto » Sat Jul 02, 2016 3:32 pm

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
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Dinamic picture change in FastReport

Postby Marcelo Via Giglio » Sun Jul 03, 2016 1:20 am

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

Re: Dinamic picture change in FastReport

Postby Mike Serra » Mon Jul 04, 2016 12:18 pm

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

Re: Dinamic picture change in FastReport

Postby Marcelo Via Giglio » Mon Jul 04, 2016 12:32 pm

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

Re: Dinamic picture change in FastReport

Postby Horizon » Fri Aug 12, 2016 8:08 pm

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 & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 119 guests