Adding an ActiveX control to a tab Page - c#

This is the code I am using:
tabPage1.Controls.Add(AXViewer1);
where AXViewer1 is a third party ActiveX control (non .NET) that I want to add to my tab page.
Is it wrong to do it the way I did, since it has not added it to the tab page with that code?

Your ActiveX control probably cannot be reparented at runtime.
You need to create a new instance of the class at runtime by writing new AXViewer().

Try setting the Visible property to True. Also try calling the CreateHandle method.
If none of this works, you are best off contacting the developer of the ActiveX control for support.

Related

Display Custom Dialog When File Downloaded

Looking for a solution to my issue. We are building a web browser control into a product for a client, they need to be able to detect when there is a File Upload box on a website, then instead of it launching the Windows 7 File Browser window, it needs to open their own custom designed one
Is there a browser event that allows us to capture that?
You can hook up your own download manager that is effective only in your webbrowser control host process by implementing IServiceProvider in the control site and implement QueryService to return an IDownloadManager object when asked by the webbrowser control
In Windows Form's Webbrowser class, a control site is created for you by default, but you can override the control site by create your own WebBrowserSiteBase class and override the WebBrowser.CreateWebBrowserSiteBase Method. There is no such extensibility if you use the webbrowser control from WPF, Silverlight or Windows Phone.
I suggest you write the download manager in C++ due to the amount of interop required if you code in C#. There's an example for a C# webbrowser control using a native download manager here.
You can catch the FileDownload event, and handle it yourself.
See http://msdn.microsoft.com/en-us/library/bb268220(v=vs.85).aspx
After showing your custom file dialog, send the data back to the webbrowser control, and submit the form.
Another option is to inject javascript into the control. Inject a code that replaces the call from the upload button, and show a form of your own instead.
So you want to modify the value of <input type=file .... You cannot do that with webbrowser control because it accesses DOM like javascript, vbscript vs. And if DOM allowed accessing and changing the uploaded file bad guys could easily steal your local files (using javascript) when you visit their pages.
Furthermore you can't even see the value of FileUpload because of that security issue.
If you want to select a file programmatically that is possible with a combination of SendKeys

How to use web browser control in the browser?

I'm trying to load a HTML page via the web browser control in my Silverlight project, but it seems that the content of the control can only be viewed from out-of-browser mode.
Is there in way to use it in the browser?
Could you give more detail? if you are wanting to control and interact with the WebBrowser Control in the Internet Explorer window, then you can do this. The code will remain the same, except you will need to change your MSHTML DOM reference when declaring your (say) HTML Document, and it'll be declared as an InternetExplorer type (comes up in intellisense after the "As" part if you're using VB, same story with c#).
Once you reference this window, you can control it - everything is the same since IE uses the WB control as well, if you however want to use the WB control in your app, you should be able to, give us some more details, are you saying that the content or links are opening up in a new external IE window? If that is the case, these things are fixable :).
Also, if you're using WPF .NET I think there is a different, less cooler WB control for that than the traditional .NET WB control. Please elaborate on your question so I can help you further.

Activex control not display properly in ie

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.

Adding GUI components to a precompiled application

iI there any way to add a GUI component to an application which is already running?
I.E. Add an extra tab into a third party GUI?
I have a third party application where I need to add an extra tab into the tabbed interface (or even a button to link to a new form).
I can see the UI components in UISpy and Spy++ but Can't see a way to alter or add them...
Any ideas? Maybe altering the memory?
Update:
The application I have created to wrap around the third party app is .NET but the third party app is written in VB6
I suppose it's entirely possible with reflection, with the aid of Reflector, assuming it's not been obfuscated. Explore around the reflected source until you find the class of the form, and the instance of the form that you want to modify, then you can invoke the Controls.Add method, or anything else you need to, with reflection. But unless you know exactly what you're doing, you could run into some unexpected behavior from the application.
You can use ResHacker.
http://www.angusj.com/resourcehacker/
Basically, each GUI form is saved as a resource inside of a particular Windows executable. ResHacker has a built-in GUI editor for editing "Dialogs" (as they are referred to in ResHacker).
I assume it's a .NET WinForm app. If you do not have the source files and the app isn't too big, you can try 'decompiling' it and add in your code to become a new app.
I'm a great fan of Lutz Roeder's Reflector which generate code from the CLR codebase.
Here's a link to his tools. http://www.lutzroeder.com/dotnet/
Update:
darkassassin93 is right, hopefully the app is not obfuscated :)
You should have strong reason for doing that.
I think you can start with Add Tab using pure WinAPI and TabCtrl_InsertItem Macro
If you have HWND of TabControl you can try to add your own tab. with TabCtrl_InsertItem. Although i don't think it's possible to do that from another process. But you should try.

Dynamically add an ActiveX control without the VS designer

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.

Categories