Re: Owner Draw STATIC Window with XP Themes

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Jeff Partch [MVP] (jeffp_at_mvps.org)
Date: 11/13/04


Date: Fri, 12 Nov 2004 22:11:39 -0600


"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
news:a257p0tq72dse8d8p9hbufletr94btqvnn@4ax.com...
> Jeff Partch [MVP] wrote:
> >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:

Hi, Doug!

I hope I didn't offend you yesterday. Anyway, I found the original post that
Dave Anderson replied to on Google, but his reply is mysteriously missing
from that archive. I tried to repro the failure that was reported using a
timer (the OP used a tight message blocking loop that I just couldn't abide,
so maybe that made the difference) and matched OTD/CTD calls, but it never
failed in any way that I could discern running for ~24 hours. So then I had
a go at the CCP. It is true, as Dave said, that there are a finite number of
slots in which to store open HTHEMEs (they are in fact coded indexes into
this array of 'theme object' pointers), but it is also true, as you say,
that matching pointers are just ref counted. So I'd have to conclude that
one would have to be up to something really far fetched to exhaust 64k of
slot positions (for what is a reasonably small finite number of 'theme
objects'). Forgive me?

Jeff...