3

I'm using the following APIs to draw a small stock icon on the background of my tab control window (with class name SysTabControl32):

DrawIconEx(hDC, rcIcon.left, rcIcon.top,
    hIconSmInfo, rcIcon.Width(), rcIcon.Height(), NULL, 
    ::GetSysColorBrush(COLOR_WINDOW),
    DI_NORMAL);

But it doesn't seem to draw consistent background. Let me show.

On a themed Windows 7:

enter image description here

It draws it correctly:

enter image description here

But if I remove themes:

enter image description here

It draws this white background:

enter image description here

So what constant do I need to use for GetSysColorBrush?

c00000fd
  • 20,994
  • 29
  • 177
  • 400
  • The introduction of themes was evil on Microsoft's part, because now you need two different code paths in far too many places. I doubt there's a single constant you can use that works in both cases. – Mark Ransom Aug 23 '15 at 02:23
  • @MarkRansom: Thanks. So I need to define if themes are enabled, right? Any recommended steps? – c00000fd Aug 23 '15 at 02:27
  • I'd start by calling [`IsThemeActive`](https://msdn.microsoft.com/en-us/library/windows/desktop/bb759813(v=vs.85).aspx). – Mark Ransom Aug 23 '15 at 02:34
  • 4
    DrawIconEx can draw icons transparently, why do you need a background color at all? – Jonathan Potter Aug 23 '15 at 03:53
  • @JonathanPotter: Oh, wow. That's embarrassing. All I needed to do was to specify `NULL` for the 8th parameter in `DrawIconEx`. Oops. Thanks. – c00000fd Aug 23 '15 at 04:14

0 Answers0