

字體顏色設定相同的情況下,如圖,若是背景色和覆寫色不同,字的顯示效果也發生了變化
看了Gauges.pas中的代碼,PaintText使用了TextRect()函式,是否與此有關,這段代碼應該如何改成DrawText函式?
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;
uj5u.com熱心網友回復:
文本顏色受到背景色的影響 是正常的。這是基于三基色合成的原理uj5u.com熱心網友回復:
但是如果是Panel Edit控制元件中修改背景色,它們的Caption就不會受到影響,我想要達到這樣的效果
uj5u.com熱心網友回復:
Canvas 的 TextRect 方法是呼叫了 Windows API: ExtTextOut 實作的uj5u.com熱心網友回復:
不用TextRect 用DrawText怎么實作?
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/103009.html
標籤:VCL組件使用和開發
上一篇:請問:ODBC如何打包到安裝程式中?用setup factory 或Installshield,或別的打包辦法?謝謝!
下一篇:IdHttp重定向POST錯誤
