Discussion:
Override a component
(too old to reply)
battles
2011-02-25 15:30:13 UTC
Permalink
procedure TCustomProgressBar.Paint;
var
DrawRct: TRect;
PercentStr: string;
begin
Canvas.Font := Font;

with Canvas do begin
DrawRct := ClientRect;
DrawRct := DrawBorderSides(Canvas, DrawRct, FBorderOuter);
if BorderWidth > 0 then
{ Fill Border }
DrawRct := DrawBevel( Canvas, DrawRct, FBorderColor,
FBorderColor,
BorderWidth, sdAllSides );
DrawRct := DrawBorderSides(Canvas, DrawRct, FBorderInner);

if FShowText
then PercentStr := S_N(FPosition, FDecimals, FDecimals) + ' ' +
FTextUnit
else PercentStr := '';

if FSmooth
then DrawLEDBar(Canvas, DrawRct, PercentStr)
else DrawPercentBar(Canvas, DrawRct, PercentStr);

end; { with }
end;

In the above procedure that is in a component I am using, I would like
to exclude the "S_N(FPosition, FDecimals, FDecimals) + ' ' +" portion
of the PercentStr string. I have tried to recompile the component
without this but I am not getting a vaild new component, mainly
because I don;t know what I am doing when it comes to component
creating.

Thanks.
Hans-Peter Diettrich
2011-02-25 18:08:37 UTC
Permalink
Post by battles
In the above procedure that is in a component I am using, I would like
to exclude the "S_N(FPosition, FDecimals, FDecimals) + ' ' +" portion
of the PercentStr string. I have tried to recompile the component
without this but I am not getting a vaild new component, mainly
because I don;t know what I am doing when it comes to component
creating.
When you modify part of the VCL, you have to recompile the VCL.

IMO you better create a new component, based on TCustomProgressBar, and
override the Paint procedure there.

Or create your own Paint handler, when the control allows for custom
drawing (OnPaint).

DoDi
Anonymous
2011-02-25 21:28:10 UTC
Permalink
Post by Hans-Peter Diettrich
Post by battles
In the above procedure that is in a component I am using, I would like
to exclude the "S_N(FPosition, FDecimals, FDecimals) + ' ' +" portion
of the PercentStr string. I have tried to recompile the component
without this but I am not getting a vaild new component, mainly
because I don;t know what I am doing when it comes to component
creating.
When you modify part of the VCL, you have to recompile the VCL.
IMO you better create a new component, based on TCustomProgressBar, and
override the Paint procedure there.
Or create your own Paint handler, when the control allows for custom drawing
(OnPaint).
DoDi
That is what I figured. I may re-install the component package after
modifying the pas to not include the "S_N(FPosition, FDecimals,
FDecimals)". The component has a ProgressBar.dcu file, so I don't know
if I can simply take that out and re-install the component package.
Again, I am not that familar with working with components. When I
tried to create a new package with the .pas, no properties showed up as
well as no component, except for something that looked like an image.
I do know that if I can't re-install the package correctly, I am
going to have mucho problems with many of my programs.
Rudy Velthuis
2011-02-26 17:35:22 UTC
Permalink
Post by Anonymous
Post by Hans-Peter Diettrich
Post by battles
In the above procedure that is in a component I am using, I would
like to exclude the "S_N(FPosition, FDecimals, FDecimals) + ' '
+" portion of the PercentStr string. I have tried to recompile
the component without this but I am not getting a vaild new
component, mainly because I don;t know what I am doing when it
comes to component creating.
When you modify part of the VCL, you have to recompile the VCL.
IMO you better create a new component, based on TCustomProgressBar,
and override the Paint procedure there.
Or create your own Paint handler, when the control allows for
custom drawing (OnPaint).
DoDi
That is what I figured. I may re-install the component package after
modifying the pas to not include the "S_N(FPosition, FDecimals,
FDecimals)".
That is the worst of the options Hans-Peter gave, IMO. You should not
create your own, modified, versions of VCL packages (you are not
allowed to distribute such modified packages anyway).

You better derive your own class from the existing one (there is a
wizard for that, under the Components menu) and override the Paint
method. Give it a different name and install it in the IDE (see here:
http://rvelthuis.de/programs/compinstall.html - this wizard has become
part of the Delphi XE IDE now, so no need to download it if you have XE
or Starter).
--
"How long would authority ... exist, if not for the willingness
of the mass to become soldiers, policemen, jailers, and
hangmen."
-- Emma Goldman
Loading...