Re: Owner Draw STATIC Window with XP Themes
From: Jonathan Wood (jwood_at_softcircuits.com)
Date: 11/11/04
- Next message: Jeff Partch: "Re: Owner Draw STATIC Window with XP Themes"
- Previous message: Jonathan Wood: "Re: DrawThemeBackground Defines--Where???"
- In reply to: Jeff Partch [MVP]: "Re: Owner Draw STATIC Window with XP Themes"
- Next in thread: Jeff Partch: "Re: Owner Draw STATIC Window with XP Themes"
- Reply: Jeff Partch: "Re: Owner Draw STATIC Window with XP Themes"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 11 Nov 2004 09:56:36 -0700
Jeff,
> Don't ge too annoyed by my jumping in here, but I think you are both
right.
> My recollected understanding of IsThemeActive and IsAppThemed is:
>
> 1) they will both return TRUE when themes are active system wide
> 2) except that IsAppThemed will return FALSE only in the case where themes
> are disabled in the compatibility properties for the application.
>
> Neither concerns itself with whether this particular app has a manifest
and
> is supposed to use themes and neither is particularly determinate as to
> whether this particular control is supposed to use themes -- only that it
> *could* -- not not that it *should*.
Right. This seems consistent with what I'm seeing.
> > Here's the function which helps maintain the theme state, called during
> > PreSubclassWindow and in response to WM_THEMECHANGED:
> >
> > void
> > OdButton::UpdateTheme()
> > {
> > if (OsVersion::AtLeastXP())
> > {
> > CloseThemeData(m_hTheme);
> > m_hTheme = (UserEx::IsAppThemed())
> > ? OpenThemeData(m_hWnd, L"button")
> > : 0;
> > }
> > }
>
> FYI, According to Dave Anderson, Microsoft Developer Support, you can't
> really do this, Doug...
>
> "
> > You should open a theme once per window... open it when the window is
> > created and close the handle when the window is destroyed. There is a
> limit
> > of 64K handles per process. The bug is when this limit is reached,
> > OpenThemeData does not return NULL.
> "
>
> Even allowing an exception for WM_THEMECHANGED, you're now doing it twice
> per window. :)
Well, that answers a question I was wondering about: whether it is okay to
open the theme data everytime you are redrawing the window. I've seen that
done many times in code I've seen on the Web. Apparently, it is better to
open it only once (even though opening it each time seems to work just
fine).
But I might be with Doug here. You must get new theme data in order to react
to a theme change, don't you? And Doug is closing the original theme before
opening a new one. It seems to me he is following Dave's advice as closely
as is practical.
-- Jonathan Wood SoftCircuits http://www.softcircuits.com Available for consulting: http://www.softcircuits.com/jwood/resume.htm
- Next message: Jeff Partch: "Re: Owner Draw STATIC Window with XP Themes"
- Previous message: Jonathan Wood: "Re: DrawThemeBackground Defines--Where???"
- In reply to: Jeff Partch [MVP]: "Re: Owner Draw STATIC Window with XP Themes"
- Next in thread: Jeff Partch: "Re: Owner Draw STATIC Window with XP Themes"
- Reply: Jeff Partch: "Re: Owner Draw STATIC Window with XP Themes"
- Messages sorted by: [ date ] [ thread ]