estoy usando DrawThemeTextEx para dibujar texto. Estoy tratando de dibujar en un color en particular mediante el miembro de crText
COLORREF de DTTOPS
estructura:Cómo cambiar el color de la fuente DrawThemeTextEx?
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;
Por desgracia, el color del texto siempre sale negro, más que el color brillante de color verde lima mi código está especificando:
i puede alterar la fuente que se utiliza por selecting the new font into the device context, es decir:
SelectObject(dc, font.Handle);
pero tampoco SetTextColor
, ni el establecimiento de las crText
y DTT_TEXTCOLOR
opciones de la estructura DTTOPS
, alterar el color del texto utilizado.
¿Cuál es confuso es que el DTTOPS structure allows me to specify a color:
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 ...
junto con la bandera DTT_TEXTCOLOR para indicar que estoy usando ese miembro:
#define DTT_TEXTCOLOR (1UL << 0) // crText has been specified
lo que quiero para lograr es documentado, pero no está funcionando bien. Obviamente estoy haciendo algo mal.
¿Cómo especifico color de texto al dibujar texto usando DrawThemeTextEx?
¿Está dibujando sobre vidrio o en un lienzo de control regular que no sea de vidrio? –
En este ejemplo, estoy dibujando en un lienzo normal (sin cristal). –