An XP style combobox in a DLL

2020-05-07 19:47发布

问题:

I need to create a combobox with an XP style IN a DLL with C++ and WIN32 API (no MFC). I managed to create the control in the DLL (by not in XP style). I managed to create XP style combobox in an exe with manifest, but it does not work in the DLL.

回答1:

In order for your DLL to load comctl v6 (the DLL that provides "XP-themed" versions of the common controls) without relying on its hosting process to have the appropriate manifest, you need to make your DLL isolation-aware.

Either use the C++ class described here in MSDN, or try #defining ISOLATION_AWARE_ENABLED=1.



回答2:

In order to force your control to use XP themed rendering regardless if it's enabled in a manifest or not you will need to use visual styles API. This is available on XP and above and provides support for rendering most common controls. More information on using the API can be found here.