Can I load more than one COMCTL32.dll into a process? - winforms

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.

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!):
(also, the icons display properly in the listbox ;))

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.

Related

WPF unable to choose right DLL if several versions are loaded within same AppDomain

We are developing plugins to be added to a giant & awesome software. We often reuse the same WPF controls so we packaged them and created separate assemblies for each of them.
Sometimes, we need to load 2 different plugins within the same instance of the software. At that point, if the 2 plugins use the same reusable control but with different DLL versions, WPF doesn't seem to be able to choose the correct one. Both DLLs are correctly loaded (seen using Process Explorer).
What we already tried :
Binding redirects
Assembly redirects
Overridden assembly resolving
Is there any solution to indicate to WPF which version of the same DLL it needs to select for requested namespace in XAML ? Could we force the use of the latest in some way (this would work for us) ?
Look at my commit o SharpDevelop: https://github.com/icsharpcode/SharpDevelop/commit/b3ea4a0efb7e3b8e083f8be40ea6f7e03ff44604
I fixed this, by using a custom "InitializComponent" Call! ("SpecialInitializeComponent") and using special merged ResourceDictionarys: VersionedAssemblyResourceDictionary! Hope that helps you!

WPF precompiled resources in WinForm application?

I am working on an application that started out as a WinForm but it is now utilizing WPF windows with UI. The interaction is all working beautifully but when the WPF windows are first shown it takes quite a long time (around 1-3 seconds) for them to show. So long that some wonder if the app has crashed (until the content shows). The second time the same windows are invoked they come up quickly. I need them to come up quickly the first time around.
I am making use of styles and control templates that are located as XAML in the resource folder. In the XAML for the WPF windows I then merge them into the windows resource dictionary. The Build Action for those (in VS 2010) needs to be set to "Resource".
Preferably I want to keep them in separate files for easy maintenance.
As far as I understand if the build action was "Page" the XAML would be precompiled and should load faster but if I set it to Page I cannot merge them into the resource dictionary. Is there a way around that?
I am fairly new to this part of WPF and so far my internet search hasn't been successful.
To be clear: I am not talking about WPF controls being embedded in WinForms. I am talking about entirely separate WPF windows that are spawned from the WinForm context.
Is there a way to precompile the entire app or at least all XAML (it's all static, no dynamic XAML)?
Thanks in advance!
Edit: The UIs are not heavy by any means. The ones in question have between 5 and 20 buttons and the usual containers (basically a grid with 1 or 2 stack panels).
Update:
I tried precompilation with "NGEN install appname" - no effect on WPF window load.
I included all resources and templates into the window.xaml - no effect.
(window.xaml is pre-compiled)
I found this really interesting article about pre-jitting upon app load here:
http://www.codeproject.com/KB/dotnet/pre_JIT.aspx
(I used the improvement suggested by 'ittay ophir')
again: no effect on WPF window load...
The load times simply won't change on first load but they are significantly reduced on all consecutive loads (loads in 20ms or less).
What the heck is going on here?
How about loading the XAML asynchronously using XamlReader.LoadAsync Method ?

Popup Outside the Bounds of the Silverlight Control

I'm simply wondering if it is possible to open one or more non-modal popups or dialogs, which are NOT limited to be displayed and moved within the bounds of the parent Silverlight control. Doesn't seem to be possible, even for out-of-browser installs. I hope I'm wrong :)
While the previous answers are true, strictly speaking it is possible in browser mode to have a real popup. At the moment it can only be done indirectly and with a lot more work than a normal Silverlight popup Window.
Basically you popup a new Silverlight app (or second instance of the current app) in a browser popup window (not a Silverlight popup). Silverlight can create the popup window via calls to Javascript.
The 2 Silverlight instances usually need to communicate data, but there are several solutions to that problem too. Javascript can also talk to Silverlight objects (love that feature) and pass information back or you could simply pass data one-way via URL parameters.
No this is not possible, Silverlight strictly renders to a single window (or if in Windowless mode the specific rectangle provided to it by its host).
As Anthony said this is not possible. I've heard from some of the people involved with Silverlight development that this is an often-requested feature and will most likely be added in an upcoming version. But I'm guessing it would only be available in "out of browser" mode.

Using ActiveX control in WPF

I'm attempting to host an ActiveX control in a WPF app. After attempting to use existing info on the web and here, I've hit a dead-end.
I need to use an ActiveX control provided to communicate with a UV power meter. They provide an application that registers and uses the control and even includes some useful demo apps. I stripped out the OCX file and put it here if needed. You won't have the power meter to talk to, but the app and demos will still load the ActiveX control successfully.
I created a simple Windows Forms application. I was able to bring the ActiveX control into the toolbar, drop it into my form, and everything is fine. The demo apps they provide do this as well.
However, getting this to work in a WPF environment is another story. The control can't be added to the toolbox and "dragged" into the app.
So far I've tried two techniques:
Technique found here. I am able to add a reference to the control, but then I enter namespace hell. The xmlns:ax namespace it suggests making cannot find the information. Here's my attempt based on what the object viewer tells me: xmlns:ax="clr-namespace:OphirUsbXLib;assembly=Interop.OphirUsbXLib"
Technique found here. This is essentially to create a new project that creates a library based on Windows Forms, which contains the ActiveX control (yikes). I am able to add the Windows Forms Host, but I cannot get access to the ActiveX control within. I can make the control public, but I still cannot call methods etc. This doesn't look like the right solution.
In short, I have an ActiveX control that works beautifully in Forms, but is a real bitch to get working in WPF.
Any insight is appreciated!
In this situation I would consider making a WinForms usercontrol which wraps the ActiveX control you are trying to use.
You could make public properties and methods which expose each of the required properties and methods on the ActiveX control, and then host this WinForms UC on the in a WPF WinFormsHost control.
I have already done something similar to this, in reverse, hosting a WPF UserControl in a WinForms UserControl, then hosting that on a VB6 Form in a legacy application.

Building Visual studio like application, need inputs

I am working on a Visual studio like application i.e. have a toolbox, an editor and property grid similar to VS.
User can drag and drop the controls(custom and third party) to the editor window and perform operations like resize, move, align, group etc.; Properties of that control needs to be displayed in property grid and user can update them from there.
As per my current understanding I will have to extend the Canvas to create my own editor and and Interface for controls which it supports; Each supported control will have to implement this interface so that it can be placed in our editor.
Something similar to this - http://www.codeproject.com/KB/WPF/WPFDiagramDesigner_Part4.aspx
Looking forward for any kind of help, comment or links.
If WPF is a requirement, wait for the VS2010 release and use the Visual Studio Shell in either isolated mode or integrated mode. Otherwise you can use the Visual Studio 2008 Shell isolated or integrated.
You'll get the docking support, addin model, editors with highlight and much more almost for free that way.
Finally, I used the Diagram designer approch to build my application. Although, I had to create my custom property grid which was painful.
Recently I came across following post which suggests that .Net DesignSurface can be used for building this kind of application -
How to create an UI Designer utility?
I have been working on a generic framework Wide to create VS like applications.
Update: Here is the CodeProject article on how to use the framework.
Wide comes with two modules and various out of the box functions:
Core module (Required)
Used for customizable splash screen
Used for Menus (supports regular menus with icon, checkable menus)
Used for Toolbar (menu view model can be reused for toolbars)
Multiple toolbars can be added to the IDE (check demo)
Themes (VS2010, VS2012 Light theme and no theme)
ThemeManager to add/remove themes
Used for Statusbar (in development)
Open file service with participatory handlers (could be based on extension or even file contents)
Save and restore layout along with opening documents
Logger module (For the logging tool)

Resources