FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Dinamic picture change in FastReport
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Dinamic picture change in FastReport
Posted: Fri Jul 01, 2016 03: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

Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
Re: Dinamic picture change in FastReport
Posted: Sat Jul 02, 2016 05: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
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: Dinamic picture change in FastReport
Posted: Sat Jul 02, 2016 02: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 (fw): Select all Collapse
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
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Dinamic picture change in FastReport
Posted: Sat Jul 02, 2016 03:32 PM
Hello,

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

Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: Dinamic picture change in FastReport
Posted: Sun Jul 03, 2016 01: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

Posts: 297
Joined: Fri Apr 14, 2006 05:52 PM
Re: Dinamic picture change in FastReport
Posted: 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

Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: Dinamic picture change in FastReport
Posted: 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 (fw): Select all Collapse
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
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Dinamic picture change in FastReport
Posted: Fri Aug 12, 2016 08: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.06

Continue the discussion