自己找到解决的办法了哈
附上代码
unit UnWdHintWnd;
interface
uses
Windows, Classes, Controls, Graphics, Forms, SysUtils, ExtCtrls,Vcl.Themes,Vcl.GraphUtil;
type
TcyHintWnd =class(THintWindow)
private
protected
procedure Paint; override; //重载显示出来的HINT文字颜色
public
constructor Create(Aowner: TComponent); override;
destructor Destroy; override;
end;
{ TcyHintWnd }constructor TcyHintWnd.Create(Aowner: TComponent);
begin
inherited Create(Aowner);end;destructor TcyHintWnd.Destroy;
begin inherited;
end;procedure TcyHintWnd.Paint;
var
R, ClipRect: TRect;
LColor: TColor;
LStyle: TCustomStyleServices;
LDetails: TThemedElementDetails;
LGradientStart, LGradientEnd, LTextColor: TColor;
begin
R := ClientRect;
LStyle := StyleServices;
LTextColor := Screen.HintFont.Color;
if LStyle.Enabled then
begin
ClipRect := R;
InflateRect(R, 4, 4);
if TOSVersion.Check(6) and LStyle.IsSystemStyle then
begin
LStyle.DrawElement(Canvas.Handle, LStyle.GetElementDetails(tttStandardNormal), R, ClipRect);
end
else
begin
LDetails := LStyle.GetElementDetails(thHintNormal);
if LStyle.GetElementColor(LDetails, ecGradientColor1, LColor) and (LColor <> clNone) then
LGradientStart := LColor
else
LGradientStart := clInfoBk;
if LStyle.GetElementColor(LDetails, ecGradientColor2, LColor) and (LColor <> clNone) then
LGradientEnd := LColor
else
LGradientEnd := clInfoBk;
if LStyle.GetElementColor(LDetails, ecTextColor, LColor) and (LColor <> clNone) then
LTextColor := LColor
else
LTextColor := Screen.HintFont.Color;
GradientFillCanvas(Canvas, LGradientStart, LGradientEnd, R, gdVertical);
end;
R := ClipRect;
end;
Inc(R.Left, 2);
Inc(R.Top, 2);
Canvas.Font.Color := clwhite;//LTextColor; //只需要更改这句代码就可以更改字体颜色
DrawText(Canvas.Handle, Caption, -1, R, DT_LEFT or DT_NOPREFIX or
DT_WORDBREAK or DrawTextBiDiModeFlagsReadingOnly);
end;initializationApplication.ShowHint := False;
HintWindowClass := TcyHintWnd;
Application.ShowHint := True;
附上代码
unit UnWdHintWnd;
interface
uses
Windows, Classes, Controls, Graphics, Forms, SysUtils, ExtCtrls,Vcl.Themes,Vcl.GraphUtil;
type
TcyHintWnd =class(THintWindow)
private
protected
procedure Paint; override; //重载显示出来的HINT文字颜色
public
constructor Create(Aowner: TComponent); override;
destructor Destroy; override;
end;
{ TcyHintWnd }constructor TcyHintWnd.Create(Aowner: TComponent);
begin
inherited Create(Aowner);end;destructor TcyHintWnd.Destroy;
begin inherited;
end;procedure TcyHintWnd.Paint;
var
R, ClipRect: TRect;
LColor: TColor;
LStyle: TCustomStyleServices;
LDetails: TThemedElementDetails;
LGradientStart, LGradientEnd, LTextColor: TColor;
begin
R := ClientRect;
LStyle := StyleServices;
LTextColor := Screen.HintFont.Color;
if LStyle.Enabled then
begin
ClipRect := R;
InflateRect(R, 4, 4);
if TOSVersion.Check(6) and LStyle.IsSystemStyle then
begin
LStyle.DrawElement(Canvas.Handle, LStyle.GetElementDetails(tttStandardNormal), R, ClipRect);
end
else
begin
LDetails := LStyle.GetElementDetails(thHintNormal);
if LStyle.GetElementColor(LDetails, ecGradientColor1, LColor) and (LColor <> clNone) then
LGradientStart := LColor
else
LGradientStart := clInfoBk;
if LStyle.GetElementColor(LDetails, ecGradientColor2, LColor) and (LColor <> clNone) then
LGradientEnd := LColor
else
LGradientEnd := clInfoBk;
if LStyle.GetElementColor(LDetails, ecTextColor, LColor) and (LColor <> clNone) then
LTextColor := LColor
else
LTextColor := Screen.HintFont.Color;
GradientFillCanvas(Canvas, LGradientStart, LGradientEnd, R, gdVertical);
end;
R := ClipRect;
end;
Inc(R.Left, 2);
Inc(R.Top, 2);
Canvas.Font.Color := clwhite;//LTextColor; //只需要更改这句代码就可以更改字体颜色
DrawText(Canvas.Handle, Caption, -1, R, DT_LEFT or DT_NOPREFIX or
DT_WORDBREAK or DrawTextBiDiModeFlagsReadingOnly);
end;initializationApplication.ShowHint := False;
HintWindowClass := TcyHintWnd;
Application.ShowHint := True;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货