Changing color on static text
Trying to change the color on some text. Got the color to change but the rest of the label is black. This is what I got in my WM_CTLCOLORSTATIC message:
static HBRUSH g_hbrBackground;
g_hbrBackground = CreateSolidBrush(RGB(0,0,0));
HDC hdc = (HDC)wParam;
SetTextColor(hdc, RGB(0, 0, 100));
SetBkMode(hdc, TRANSPARENT);
return (LONG)g_hbrBackground;
I''m missing something but I don''t know what it is.
''the rest of the label is black''
of course it is, since you are returning a black brush (RGB(0,0,0)) for the background, or did i get you wrong?
of course it is, since you are returning a black brush (RGB(0,0,0)) for the background, or did i get you wrong?
Thanks for that amazing reply. But I was actually looking for a little help on how to change the background to the dialog color instead of back.
this is what i''ve used in the past:
LOGBRUSH lbBkgnd;
lbBkgnd.lbStyle = BS_HOLLOW;
lbBkgnd.lbColor = 0;
lbBkgnd.lbHatch = 0;
ghTransBrush = CreateBrushIndirect(&lbBkgnd);
ghTransBrush would be equivalent to your g_hbrBackground.
LOGBRUSH lbBkgnd;
lbBkgnd.lbStyle = BS_HOLLOW;
lbBkgnd.lbColor = 0;
lbBkgnd.lbHatch = 0;
ghTransBrush = CreateBrushIndirect(&lbBkgnd);
ghTransBrush would be equivalent to your g_hbrBackground.
you can also use lbStyle = BS_SOLID and lbColor = GetSysColor(COLOR_BTNFACE) if you want to use a solid colored brush, although I don''t know how well this works with themed windows/controls. COLOR_BTNFACE would pick up the color for button controls, but you could substitute another type if you wanted (like COLOR_WINDOW).
COLOR_BTNFACE, that was what I was looking for but couldn''t remember for the life of me. I used what you posted and it works. But I had to set the color on the other text labels so they were black. Not a big deal though.
You wouldn''t happen to know how to underline the text in the label? If you hadn''t figured it out I''m trying to make a couple of ''URLs'' in my about dialog.
You wouldn''t happen to know how to underline the text in the label? If you hadn''t figured it out I''m trying to make a couple of ''URLs'' in my about dialog.
sorry my first response wasn't very helpful, but since my standard windows background color is black i didn't get what the problem for you was
anyway, i just did the same (statics as clickable links) last week, so i can help you here:
1) you can get the brush 'easier' if you just call GetSysColorBrush(COLOR_BTNFACE), which relieves you of having to free any created brushes at the end.
2)
then you can switch between normal and underlined font via SendMessage with WM_SETFONT
[edited by - burning_ice on May 2, 2003 4:27:06 PM]
anyway, i just did the same (statics as clickable links) last week, so i can help you here:
1) you can get the brush 'easier' if you just call GetSysColorBrush(COLOR_BTNFACE), which relieves you of having to free any created brushes at the end.
2)
HFONT NormalFont = (HFONT) SendMessage ( controlwindow, WM_GETFONT, 0, 0 ); // create underlined version of the same font LOGFONT lf; GetObject ( NormalFont, sizeof(LOGFONT), &lf ); lf.lfUnderline = TRUE; HFONT UnderlinedFont = CreateFontIndirect ( &lf );
then you can switch between normal and underlined font via SendMessage with WM_SETFONT
[edited by - burning_ice on May 2, 2003 4:27:06 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement