Heres the deal... I wrote an MFC extension DLL GUI library. It does all the
fancy controls, etc. I'm trying to optimize a few aspects of it. In a lot of
places, it obviously needs to know if themes are active or if its in high
contrast mode, etc. I have these functions working, but they seem to be
creating a bit of overhead as they are called a LOT. I want to cache that
value, but what would be a slick way to refresh these cached values? In
order to have everything draw correct, I would need to handle
need to handle them BEFORE ANY OTHER WINDOW in the application.

There are a few requirements:

1) I need to handle these 3 message before any other window in the process
2) I can not depend on the developer to handle them properly and send them
to my DLL
3) It must be EXTREMELY low overhead. Ie.. the point is to optimize the
calls by caching the values, but if trapping the 3 messages early enough is
going to put a higher burden on the system then just calling the functions
directly, thats not acceptable.
4) There is one "Initialize()" function that the developer calls into my
library and one "Terminate()" function. All the capturing/hooking, etc must
be handled transparently in those two functions.
5) It must be generic to any type of app: sdi, mdi, multi-top level, dialog,

Any ideas???

MFC seems to do something similar by having CWnd base handlers call update
functions if its the main application window. Is the main application window
always guaranteed to get the messages before other windows? what about popup
windows like floating toolbars? those aren't children of the main frame when
they are floating.