Home > Back-end >  TGauge text color is affected by the background color
TGauge text color is affected by the background color

Time:10-01



Font color Settings the same situation, as shown in figure, if the background color and cover color is different, word display effect also change
Looked at the Gauges. The code in the pas, use PaintText TextRect () function, is involved in this, how should this code into a DrawText function?
 procedure TGauge. PaintAsText (AnImage: TBitmap; PaintRect: TRect); 
Var
S: a string;
X, Y: Integer;
OverRect: TBltBitmap;
The begin
OverRect:=TBltBitmap. Create;
Try
OverRect. MakeLike (AnImage);
PaintBackground (OverRect);
S:=Caption;
//S=Format (' % d % % '[PercentDone]);
With OverRect. Canvas do
The begin
Brush. Style:=bsClear;
The Font:=the Self. The Font;
The Font Color:=clWhite;
With PaintRect do
The 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. The Draw (0, 0, OverRect);
The finally
OverRect. Free;
end;
end;

CodePudding user response:

Text color is affected by the background color is normal, this is the principle of synthesis based on three primary colors

CodePudding user response:

reference 1st floor songhtao response:
text color is affected by the background color is normal, this is based on three primary colors of synthetic principle


But if it is a Panel in the Edit control changes the background color, the Caption would not be affected, I want to achieve such effect

CodePudding user response:

Canvas TextRect method is to call the Windows API: ExtTextOut

CodePudding user response:

reference ccrun reply: 3/f
Canvas TextRect method is to call the Windows API: ExtTextOut implementation of


Don't TextRect DrawText how to implement?
  • Related