Question

I'm developing an ActiveX control which (these days) is used mostly in WinForms apps.

The ActiveX control has a 'property page' dialog, which can be shown programmatically using the ShowPropertyPages method on the AxHost class. This is the custom UI that can be brought up in Visual Studio to edit a control's properties.

This property page dialog contains a ListBox control which uses an ImageList to display icons next to list items. These icons are 32-bit alpha-blended bitmaps. In order for these to display properly, version 6.0 or above of COMCTL32.DLL must be used.

Unfortunately when I run my WinForms app, it loads and uses COMCTL32.DLL version 5.xxx. As a result, when the property page dialog is displayed the icons look bad (the semi-transparent areas are drawn in solid black).

My question is: is there any way I can make sure to use COMCTL32.dll version 6.0+ from within the ActiveX control's property page UI, regardless of what the process is using? Or can I force the host process to use version 6.0? (I think not, because I am thinking the host process might have already loaded COMCTL32.DLL into memory before any of the code in the ActiveX control.

This webpage covers some scenarios for using COMCTL32 6.0, but not the situation I am in.

Was it helpful?

Solution

The original MSDN article was confusing me because it focussed on a number of specific scenarios, none of which matched mine. In fact, the underlying technology it is talking about works more generally.

By adding a 'manifest' xml file resource to the ActiveX DLL, I can signal to the side-by-side system that I want that DLL to use COMCTL32.DLL 6.x. That version is then loaded automatically. Pretty nice.

This manifest needs to be resource type RT_MANIFEST, with a resource ID of 2.

Here's the evidence of success (two versions of the same DLL loaded in the same process!): procexp screenshot showing two COMCTL32's loaded in process

(also, the icons display properly in the listbox ;))

OTHER TIPS

If your application calls Application.EnableVisualStyles() (typically before calling Application.Run() to start a message loop) then version 6+ of the common controls library should be used.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top