In the report its required to write a text with fixed width into TfrxMemoView ,reducing font size from 10 and below , until the smallest . How can this be done ?

Question: In the report its required to write a text with fixed width into TfrxMemoView ,reducing font size from 10 and below , until the smallest . How can this be done ?

Answer:

Use the function TfrxMemoView.CalcWidth in the TfrxMemoView.OnAfterData:

1
2
3
4
5
6
procedure Memo1OnAfterData(Sender: TfrxComponent);
begin
 Memo1.Font.Size:=10; 
 if Memo1.CalcWidth>Memo1.Width-Memo1.GapX*2 then
 Memo1.Font.Size:=Trunc(Memo1.Font.Size*((Memo1.Width-Memo1.GapX*2)/Memo1.CalcWidth)); 
end;