Delphi 如何更改主题图Themetextex字体颜色?

Delphi 如何更改主题图Themetextex字体颜色?,delphi,winapi,themes,uxtheme,Delphi,Winapi,Themes,Uxtheme,我用它来画文本。我试图使用DTTOPS结构的crTextCOLORREF成员以特定颜色绘制它: procedure DrawThemeText(dc: HDC; text: WideString; font: TFont; pt: TPoint; foreColor: COLORREF); var R: TRect; dttOpts: TDttOpts; hOldFont: HFONT; oldColor: COLORREF; begin foreColor :=

我用它来画文本。我试图使用
DTTOPS
结构的
crText
COLORREF成员以特定颜色绘制它:

procedure DrawThemeText(dc: HDC; text: WideString; font: TFont; pt: TPoint; foreColor: COLORREF);
var
   R: TRect;
   dttOpts: TDttOpts;
   hOldFont: HFONT;
   oldColor: COLORREF;
begin
   foreColor := $FF00FF00; //bright lime green
   font.

   R := Rect(pt.x, pt.y, $7fffffff, $7fffffff);

   ZeroMemory(@dttOpts, SizeOf(TDTTOpts));
   dttOpts.dwSize := SizeOf(TDTTOpts);
   dttOpts.iGlowSize := 1;
   dttOpts.crText := foreColor;
   dttOpts.dwFlags := DTT_GLOWSIZE or DTT_TEXTCOLOR;

   hOldFont := SelectObject(dc, font.Handle);
   oldColor := SetTextColor(dc, foreColor);
   try
      hr := DrawThemeTextEx(ThemeServices.Theme[teWindow], DC, WP_CAPTION, CS_ACTIVE, 
            PWideChar(Text), Length(Text),
            DT_LEFT or DT_TOP or DT_SINGLELINE or DT_NOPREFIX, R, dttOpts);
   finally
      SetTextColor(dc, oldColor);
      SelectObject(dc, hOldFont);
   end;
不幸的是,文本颜色总是显示为黑色,而不是我的代码指定的明亮的石灰绿色:

我可以更改所使用的字体,即:

但无论是设置结构的
crText
DTT\u TEXTCOLOR
选项,都不会改变所使用的文本颜色

令人困惑的是:

与DTT_TEXTCOLOR标志一起指示我正在使用该成员:


#define DTT_TEXTCOLOR(1UL该
crText
成员是一个
ColorRef
。高阶字节“必须为零。”

您是在玻璃画布上还是在常规非玻璃控件画布上绘图?在本例中,我是在常规(非玻璃)画布上绘图。
   SelectObject(dc, font.Handle);
typedef struct _DTTOPTS
{
    DWORD             dwSize;              // size of the struct
    DWORD             dwFlags;             // which options have been specified
    COLORREF          crText;              // color to use for text fill
    COLORREF          crBorder;            // color to use for text outline
    COLORREF          crShadow;            // color to use for text shadow
    ...
   #define DTT_TEXTCOLOR       (1UL << 0)      // crText has been specified