Re: Owner Draw STATIC Window with XP Themes

From: Jeff Partch (jeffp_at_mvps.org)
Date: 11/11/04


Date: Thu, 11 Nov 2004 13:26:30 -0600


"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
news:a257p0tq72dse8d8p9hbufletr94btqvnn@4ax.com...
> Jeff Partch [MVP] wrote:
> >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*. That leaves the similarly flawed
> >GetThemeAppProperties, and GetWindowTheme which I discuss below.
>
> I'm with you so far. ISTR a problem with IsThemeActive, causing me to use
> IsAppThemed, which has been reliable for me in apps known to have a
> manifest.

Just to let you know I recognize that you say later that you don't care
about the no manifest case, or the removed themes via SetWindowTheme, but
these are real concens in general aren't they?

> >cases. And IIRC, there are folks doing things with the activation context
to
> >disable theming after the fact even in an otherwise themed app with a
> >manifest.
>
> Example? I'm so not familiar with activation contexts. I guess if you were
> going for full generality, you'd have to worry about those things.

I'l try and drum up what I was remembering sometime today. I couldn't find
it in the archives this morening, and was getting no hits on google even for
things I know were there.

> >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. :)
>
> Can't do what? Each OpenThemeData has a matching CloseThemeData. The
> WM_THEMECHANGED docs say:

I did and do allow that WM_THEMECHANGED has to be handled as documented. But
I think what Dave was saying is that there is a bug in the implementation
and this is the way to work around it. I've never even check whether he was
all wet about it, I was just quoting what he said do. I've done all the
things you listed too, Doug and they work for me as well. I was just
alerting you to what an MS representative said about the practice. Remember
this is how we all learned about the only UNICODE apps can use themes rule.
:)

> The Visual Styles documentation is among the worst in MSDN. It was
horribly
> incomplete and ambiguous when it first came out, and reviewing it now, it
> seems not to have improved much. For my purposes, IsAppThemed() has worked
> reliably to determine if controls should be themed, but then again, I
don't
> have any controls that have disabled themes with SetWindowTheme, and as
> mentioned earlier, I'm not concerned with apps that may not have a
manifest.
> These considerations aside, I've observed zero problems with the method
I've
> been using for 3+ years, and I've had no reports of any problems with it
for
> apps that run on Windows 9x and NT4 and later. The documentation gives no
> hint the approach shouldn't work; on the contrary, it gives examples
> indicating it should work. The test app I just wrote seems to confirm the
> approach is sound. So as long as it ain't broke... :)

I'm not blowing off all your fine arguments, Doug. It's just that I'm at
work right now and haven't the time to consider them fully to see if I even
have any counter. In a quick read through, I see nothing to disagree with
except that using an MS sample as the right way to do anything is in my
experience not wise. :)

I'll get back to this later tonight anad see if I can figure out what Dave
was really addressing and see if I can prove or disprove it.

-- 
Jeff Partch [VC++ MVP]


Relevant Pages

  • Manifest Files
    ... I'm fairly new to app security and manifests. ... confused - if the manifest file is embedded into the assembly, ... intended recipient, please inform the sender and delete all copies. ...
    (microsoft.public.dotnet.security)
  • Re: Vista registry programming
    ... Vista-like noises (it's easy...you just go to the manifest section of the MSDN, ... currently-shipping system even though its a new app). ... The root key of our registry tree had modified security to ... not only are the registry security ...
    (microsoft.public.vc.mfc)
  • Re: Owner Draw STATIC Window with XP Themes
    ... >>Neither concerns itself with whether this particular app has a manifest ... > have any controls that have disabled themes with SetWindowTheme, ... I'm not blowing off all your fine arguments, Doug. ...
    (microsoft.public.vc.mfc)
  • Re: Some interesting things about XML...
    ... Each APRD Chain may contain a variable number of entries. ... > gdi.dll does some interesting things with .manifest files. ... > Microsoft has also programmed Internet Explorer to read the ... > same folder the app resides in, so if you had an app titled ...
    (alt.lang.asm)
  • Re: Manifest+MFC80.dll = neue DLL-Hölle?
    ... Meiner Meinung nach beseitigt gerade das Manifest das DLL Problem. ... dann startet die App nicht. ... dass die CRT aei der 8.0 verwendet. ...
    (microsoft.public.de.vc)