Lazarus

Programming => Packages and Libraries => LazReport => Topic started by: ahiggins on January 29, 2012, 07:36:50 pm

Title: Lazreport changing fonts at runtime
Post by: ahiggins on January 29, 2012, 07:36:50 pm
Is there an easy way to change the font at runtime.

If View.Name='Memo14' then
     begin
          If TitleBar Then View.FillColor:=clSilver else
          View.FillColor:=clWhite;
          If TitleBar Then View.Width:=696 else View.Width:=400;
     end;

as well as changing the colour and width i would also like to change the font to bold
Title: Re: Lazreport changing fonts at runtime
Post by: Lam.Abdeldjalil on January 29, 2012, 10:39:44 pm
hi ,

try it this way

Code: [Select]
(frReport1.Pages.Pages[0].FindObject('memo14') as TfrMemoView).Font.Size:=20;
(frReport1.Pages.Pages[0].FindObject('memo14') as TfrMemoView).Width:=200;

good luck ;
Title: Re: Lazreport changing fonts at runtime
Post by: ahiggins on January 31, 2012, 11:47:42 am
many thanks for the reply. But i cant get it to work. Im not sure what im doing wrong but i just can't change the fonts bold status at runtime, any ideas?
I've found a dirty work around, i used two memos overlayed on top of each other, one bold one not, then  just switch the visible status of them both depending if Titlebar is true or not.   
Title: Re: Lazreport changing fonts at runtime
Post by: felipemdc on January 31, 2012, 12:50:48 pm
Did yo try:

(frReport1.Pages.Pages[0].FindObject('memo14') as TfrMemoView).Font.Style:=[fsBold];

?
Title: Re: Lazreport changing fonts at runtime
Post by: ahiggins on January 31, 2012, 02:31:21 pm
Just tried it, still no joy. looks like i will have to stick with the dirty workaround. Oh I'd just like the thank everyone who works on the Free Pascal & Lazarus projects. I use the both of them every day at work, and am still amazed  the power these tools provide. Many thanks.
Title: Re: Lazreport changing fonts at runtime
Post by: cristianorta on February 22, 2013, 03:56:45 am
Sorry for my bad English!
If i put the code:
if x=true then
       (frReport1.Pages.Pages[0].FindObject('Memo4') as TfrMemoView).Font.Style:=
                 (frReport1.Pages.Pages[0].FindObject('Memo4') as TfrMemoView).Font.Style+[fsBold];
in OnGetValue Memo4 is always bold but if i put the code:
if x=true then
       (frReport1.Pages.Pages[0].FindObject('Memo4') as TfrMemoView).Font.Style:=
                 (frReport1.Pages.Pages[0].FindObject('Memo4') as TfrMemoView).Font.Style+[fsBold]
else
       (frReport1.Pages.Pages[0].FindObject('Memo4') as TfrMemoView).Font.Style:=
                 (frReport1.Pages.Pages[0].FindObject('Memo4') as TfrMemoView).Font.Style-[fsBold];
Memo4 is never bold.

What am i doing wrong?
Title: Re: Lazreport changing fonts at runtime
Post by: cristianorta on March 20, 2013, 04:04:25 am
To change fonts at runtime put code in LazReport Memo Field.

if [repoDS."IzqResaltado"]=true then FontStyle:=2 else FontStyle:=0;

Thanks to Profesor Carlos

http://professorcarlos.blogspot.com.ar/2010/06/lazarus-dicas-de-lazreport.html (http://professorcarlos.blogspot.com.ar/2010/06/lazarus-dicas-de-lazreport.html)
Title: Re: Lazreport changing fonts at runtime
Post by: JP.NUAGE on November 26, 2013, 09:48:54 am
Sorry for that, but I'm afraid this code doesn't work
I code in the Memo Script

Memo13.Visible := [MYTABLE."CASH"] <> 0;
if [MYTABLE."CASH"] < 0 then
  FontStyle := 2;

Then I tried

Memo13.Visible := [MYTABLE."CASH"] <> 0;
if [MYTABLE."CASH"] < 0 then
  Memo13.FontStyle := 2;

For null values, Memo13 is invisible. But for negative values, no change is to be seen on the report

What did I do wrong ?
 
TinyPortal © 2005-2018