Need to "shift right relative to" in RAP
Dear Sirs,
I need a lable or variable to shift right within a report template
not connected to a form. So, this would have to happen in the RAP
somewhere.
The code provide in the General news group works in a form, since the
TCanvas is not available in RAP. Tried using the
TppDBtext.Region.DesignControl.Canvas.TextWidth(), but it will not
compile in RAP.
Is there any Tpp component with a canvas that can be used to get the
text width?
procedure SetLabelLeftValue(aLabel1, aLabel2: TppDBText; aCanvas: TCanvas);
var
liLabelWidth: Integer;
begin
aCanvas.Font := aLabel1.Font;
liLabelWidth := aCanvas.TextWidth(aLabel1.Text);
aLabel2.Left := aLabel1.Left + liLabelWidth + 16;
end;
Thanks,
Dave
I need a lable or variable to shift right within a report template
not connected to a form. So, this would have to happen in the RAP
somewhere.
The code provide in the General news group works in a form, since the
TCanvas is not available in RAP. Tried using the
TppDBtext.Region.DesignControl.Canvas.TextWidth(), but it will not
compile in RAP.
Is there any Tpp component with a canvas that can be used to get the
text width?
procedure SetLabelLeftValue(aLabel1, aLabel2: TppDBText; aCanvas: TCanvas);
var
liLabelWidth: Integer;
begin
aCanvas.Font := aLabel1.Font;
liLabelWidth := aCanvas.TextWidth(aLabel1.Text);
aLabel2.Left := aLabel1.Left + liLabelWidth + 16;
end;
Thanks,
Dave
This discussion has been closed.
Comments
The TextWidth method is not available in RAP. You will need to create a
passthru function to gain access to the TextWidth method.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
HTH bernd
type
TComponentGetRightEnd = class(TraSystemFunction)
public
procedure ExecuteFunction(aParams: TraParamList); override;
class function GetSignature : string; override;
end;
class function TComponentGetRightEnd.GetSignature : string;
begin
Result:='function ComponentGetRightEnd(aComponent:TComponent): Integer;';
end;
procedure TComponentGetRightEnd.ExecuteFunction(aParams: TraParamList);
var
lCustomText: TppCustomText;
lBitmap : TBitmap;
aComponent : TComponent;
liTextWidth: Integer;
liPosition : Integer;
begin
// use spLeft:=GetRightEnd instead of Left:= !!
GetParamValue(0,aComponent);
lCustomText:=TppCustomText(aComponent);
lBitmap:=TBitmap.Create;
lBitmap.Canvas.Font:=lCustomText.Font;
liTextWidth:=lBitmap.Canvas.TextWidth(lCustomText.Text);
liPosition:=lCustomText.spLeft+liTextWidth;
lBitmap.Free;
SetParamValue(1,liPosition);
end;
initialization
raRegisterFunction('ComponentGetRightEnd',TComponentGetRightEnd);
finalization
raUnRegisterFunction('ComponentGetRightEnd');
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com