Is it possible loading C# form (or C# application) into ActiveX control? I know how to load ActiveX control to C# form....
You can call a .Net form in VB6 (with Interop Forms Toolkit 2.0), and you can use VB6 to create an ActiveX so my guess is that it is possible.
I have also heard of ppl used forms created from .net-dlls and den using setparent-api and got it to act as a child to vb6-form.
All in all, yes it seems possible to load an C#-form in an activeX control.
Interop Forms Toolkit 2.0: display .NET Winforms in VB6 Applications
http://hubpages.com/hub/Interop_Forms_Toolkit_20
And someone using SetParent, not a solution but from this its easy to google away to other solutions.
http://www.eggheadcafe.com/forumarchives/NETFrameworkinterop/Oct2005/post24062147.asp
Related
My Project Consists of Four Items
C# DLL Which Exposes a COM Interface via Interop
A WPF Control which contains an Instance of an exposed class in 1
A Winform ActiveX which hosts the WPF control in 2 using ElementHost
An MFC Dialog Application using the Control from 3
The Winform ActiveX (3) exposes the class instance from 1 via a function in 2. I wish to access this class instance from the MFC dialog application through the ActiveX. I have looked around and found you can do this using CWinFormControl. However I am not at liberty to recompile the MFC app using /clr. Therefore I cannot use CWinFormControl.
I can access the class in 1 via COM from the MFC app and run all the functions etc however the class is a different instance as the DLL is loaded in its own space.
The ActiveX works well and displays all the WPF data nicely.
So the question is how do I get a pointer to the ActiveX control from within the MFC app without using CWinFormControl?
I have tried importing the TLB from the ActiveX and attempting to create a "Variable" for it in the Class wizard but it reports that the TLB is unavailable. I have also tried directly creating a DDX entry by manually creating a variable but DDX doesn't allow pointers.
Any ideas?
The Question is basically trying to access a Winform ActiveX Control in MFC without having to use clr or managed C++.
For anyone interested in the answer to this question here is how I solved it. First off you have to dynamically create the ActiveX and place it your self.
In Your MFC Dialog header add a CWnd
CWnd m_MyActiveX;
In your MFC Cpp dynamically create the Control
m_MyActiveX.CreateControl("MyActiveX.ProgId","",WS_VISIBLE,prect,this,5000);
NOTE: you can find the progid in your Winform ActiveX attributes
[ProgId("MyActiveX.ProgId")]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
Next Grab the IUnknown and QueryInterface for the COM Object You need
IOleObjectPtr pOleObj(m_MyActiveX.GetControlUnknown ());
if (pOleObj != NULL)
{
MyCOMObject::IWpfHostPtr host;
pOleObj.QueryInterface(__uuidof(MyCOMObject::IWpfHostPtr),&host);
MyCOMWPFControl::IWpfControl wpf;
host->GetWpfControl ( &wpf );
MyInternalCOMObject::ICoolObject internal;
wpf->GetInternalObject ( &internal );
internal->AndAPartridgeInaPearTree ();
}
NOTE: The Actual Winform ActiveX must derive from some known Interface
public partial class WpfHost : UserControl, IWpfHost
Using this Technique you successfully host WPF Controls on your Legacy MFC Applications and communicate with them via COM without resorting to Managed C++
hi i am using activex control in my asp.net application.
I add a reference of dll and write code
object id="vb" name="vbvbnv" classid="Bin/ClassLibrary5.dll#ClassLibrary5.UserControl1"
but when i run it's shows me output like this
http://screencast.com/t/ii87CY99j
in my activex control i use only button but it is not display there
The syntax that you're showing here is not ActiveX but instead what's called a UserControl. These are disabled in IE8 and later.
http://blogs.msdn.com/b/ieinternals/archive/2009/10/09/dotnet-usercontrols-do-not-load-in-ie8-internet-zone.aspx
Generally speaking, you should not write code to run inside IE in .NET languages.
ActiveX is a client-side code, so it needs to be installed on client's machine.
You should pack it as described here: Packaging ActiveX Controls.
I was wondering if ASPX page can use WPF Controls (from the toolbox in the designer)?
Because I have a custom user control that I made for a application before but now i am creating a web app. In the web app the controls were grayed out.
I was wondering if there is a way to use the user control in the web app?
Unfortunately, you'll have to create a new ASP.Net control that mimics your WPF control. The two technologies have completely different approaches to rendering (DirectX primitives vs. HTML), events (Routed events vs. Postbacks), etc. and are simply not compatible.
That being said, converting a WPF control to a Silverlight control is doable, and would allow you to leverage your previous work. You would still need to run it through a Silverlight app, though, rather than directly through the ASPX page.
ASP.NET is primarily a server side framework and WPF applications run on the client, therefore they don't really work well together. You might find it easier to convert the WPF control into a Silverlight control instead and pass that through your ASP.NET page. Users will need a Silverlight plugin to run it.
These two posts might help in the conversion:
Porting from WPF to Silverlight: The Missing Pieces, Part 1
Porting from WPF to Silverlight: The Missing Pieces, Part 2
We have a 3rd party ActiveX control namely Autodesk's "Design Review" that we would like to use in a non aspx environment. Most functionality is available through javascript, however one key method cannot be called from that environment. Searching on the Autodesk forums we found a solution that involves creating a COM wrapper around the control. I would assume that wrapper would then make the necessary modifications to the arguments passed in from javascript.
I assume this could be done by creating a C++ COM object wrapping the control. My question though is, can this be done in c# .net? We don't want to embed the control in a Windows form and pop it up on the web page. We can actually do this easily. What we want is to embed the control in the web page.
You can create a an assembly from the activex control using Windows Forms ActiveX Control Importer
ActiveX is COM so the technology for embedding it in a page has not change for 10-12 years ago. It is just plain HTML, with Object tag. This is pre-.NET and .NET has not made any enhancements last time I checked.
You can run C# and host it in IE and use ActiveX like that but you do not want to do it.
Have a look here:
http://www.w3schools.com/TAGS/tag_object.asp
I must say, however, that with all the limitations on running ActiveX in IE - because it was a security hole - it will not be a pleasant user experience for its users.
I'm trying to dynamically add an ActiveX control to my application, without having to place it on a form.
However, when I do place the ActiveX control using the Visual Studio designer, initialization code is generation which contains a statement for setting for OcxState of the ActiveX control.
When an ActiveX control is added to a form using the designer, it seems like that the OcxState is serialized into a resources file, which is later retrieved at the initialization of the form.
Now I want to set that OcxState dynamically in code, so I can create some kind of wrapper class for the ActiveX for in my class library.
Anyone knows how to dynamically set the OcxState of an ActiveX control?
Thanks in advance!
Mathieu
i working in the same problem, the solution i got by now is working with a Worker form, that is not show, but where i can load the ocx and wrapper all the events and methods of the ocx to the outside.
In my library class i use the form like any other class instead of the ocx calls
I had the same problem while I was working on a .NET project that requires an ActiveX control for data manipulation. I had to put the ActiveX control on a form, load it with the application and use it with a public property. Otherwise if I just create an instance of the control I loose some of the functionality.
The form does not require to be visible all the time but it provides a container where the ActiveX control can live.
The another way is UserControl,
You can create a user control with your ActiveX Control. Now you can load the user control at wherever you want dynamically at runtime.