Center Vertically in Band with code in a procedure
Dear friends,
I wrote below procedure for auto font fix long length of last_ name
field and do work well, but after reduced font size I'd like add code to
following which do "Center Vertically in Band".
I do it with RB Designer and always displace Center Vertically in Band
after any reduced font size.
class procedure TmyReportUtils.AutoFontSize(aReport: TppCustomReport);
var
liBand: Integer;
liObject: Integer;
lObject: TppComponent;
begin
for liBand := 0 to aReport.BandCount-1 do
for liObject := 0 to aReport.Bands[liBand].ObjectCount-1 do
begin
lObject := aReport.Bands[liBand].Objects[liObject];
If( ( TppDBText(lObject).DataField = 'last_name') and ( 60 <= Length
(TppDBText(lObject).DataPipeline['last_name']) ) ) then
TppDBText(lObject).Font.Size := 3
else If( (TppDBText(lObject).DataField = 'last_name') and (50 <=
Length(TppDBText(lObject).DataPipeline['last_name'])) and ( Length
(TppDBText(lObject).DataPipeline['last_name']) < 60) ) then
TppDBText(lObject).Font.Size := 4
else If( (TppDBText(lObject).DataField = 'last_name') and (40 <=
Length(TppDBText(lObject).DataPipeline['last_name'])) and ( Length
(TppDBText(lObject).DataPipeline['last_name']) < 50) ) then
TppDBText(lObject).Font.Size := 5
else If( (TppDBText(lObject).DataField = 'last_name') and (30 <=
Length(TppDBText(lObject).DataPipeline['last_name'])) and ( Length
(TppDBText(lObject).DataPipeline['last_name']) < 40) ) then
TppDBText(lObject).Font.Size := 6
else if (lObject is TppSubreport) then
AutoFontSize(TppSubReport(lObject).Report); // recursive call
for childreport
end;
end;
Regards,
Ali Abbasi
--- posted by geoForum on http://delphi.newswhat.com
I wrote below procedure for auto font fix long length of last_ name
field and do work well, but after reduced font size I'd like add code to
following which do "Center Vertically in Band".
I do it with RB Designer and always displace Center Vertically in Band
after any reduced font size.
class procedure TmyReportUtils.AutoFontSize(aReport: TppCustomReport);
var
liBand: Integer;
liObject: Integer;
lObject: TppComponent;
begin
for liBand := 0 to aReport.BandCount-1 do
for liObject := 0 to aReport.Bands[liBand].ObjectCount-1 do
begin
lObject := aReport.Bands[liBand].Objects[liObject];
If( ( TppDBText(lObject).DataField = 'last_name') and ( 60 <= Length
(TppDBText(lObject).DataPipeline['last_name']) ) ) then
TppDBText(lObject).Font.Size := 3
else If( (TppDBText(lObject).DataField = 'last_name') and (50 <=
Length(TppDBText(lObject).DataPipeline['last_name'])) and ( Length
(TppDBText(lObject).DataPipeline['last_name']) < 60) ) then
TppDBText(lObject).Font.Size := 4
else If( (TppDBText(lObject).DataField = 'last_name') and (40 <=
Length(TppDBText(lObject).DataPipeline['last_name'])) and ( Length
(TppDBText(lObject).DataPipeline['last_name']) < 50) ) then
TppDBText(lObject).Font.Size := 5
else If( (TppDBText(lObject).DataField = 'last_name') and (30 <=
Length(TppDBText(lObject).DataPipeline['last_name'])) and ( Length
(TppDBText(lObject).DataPipeline['last_name']) < 40) ) then
TppDBText(lObject).Font.Size := 6
else if (lObject is TppSubreport) then
AutoFontSize(TppSubReport(lObject).Report); // recursive call
for childreport
end;
end;
Regards,
Ali Abbasi
--- posted by geoForum on http://delphi.newswhat.com
This discussion has been closed.
Comments
I would suggest getting the text width using the TCanvas.TextWidth routine
after the font has been adjusted, then use that information to re-position
the text component based on the band width.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thank you very much for replay.
-You told me which I use from TCanvas.TextWidth for getting text width
but I studied Developer's Guide and I could not did it.
So, please help me which I write it code for this procedure.
-Do I use "Center Vertically in Band" "of RB designer with code (similar
View\Toolbar\Align or Space\Center Vertically in Band)?
If yes, what is it code for this procedure?
Because I think "Center Vertically in Band" of RB designer can fix my
problem.
Best regards,
Ali Abbasi
////////////////////////////////////////////////////
routine
position
--- posted by geoForum on http://delphi.newswhat.com
Sorry, I missread your post. To center vertically, you will want to use the
TCanvas.TextHeight routine to discover the height of the text before
repositioning it based on the height of the band. For information on how
the TextHeight routine works, see the corresponding topic in the Delphi
help.
The most common way to access a TCanvas object is by creating a TBitmap and
using its Canvas property.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
We added to 1 or 0.9 or 0.8? to top of DBText and fixed my problem.
Thank you and Best regards,
Ali Abbasi
use the
how
and
--- posted by geoForum on http://delphi.newswhat.com
I added to 1 or 0.9 or 0.8? to top of DBText and fixed my problem.
Thank you and Best regards,
Ali Abbasi
use the
how
and
--- posted by geoForum on http://delphi.newswhat.com