604
社区成员
发帖
与我相关
我的任务
分享
procedure TGauge.PaintAsText(AnImage: TBitmap; PaintRect: TRect);
var
S: string;
X, Y: Integer;
OverRect: TBltBitmap;
begin
OverRect := TBltBitmap.Create;
try
OverRect.MakeLike(AnImage);
PaintBackground(OverRect);
S := Caption;
// S := Format('%d%%', [PercentDone]);
with OverRect.Canvas do
begin
Brush.Style := bsClear;
Font := Self.Font;
Font.Color := clWhite;
with PaintRect do
begin
X := (Right - Left + 1 - TextWidth(S)) div 2;
Y := (Bottom - Top + 1 - TextHeight(S)) div 2;
end;
TextRect(PaintRect, X, Y, S);
end;
AnImage.Canvas.CopyMode := cmSrcInvert;
AnImage.Canvas.Draw(0, 0, OverRect);
finally
OverRect.Free;
end;
end;