Click here to Skip to main content
Licence CPOL
First Posted 13 Feb 2007
Views 14,761
Bookmarked 7 times

Using late binding to ActiveX controls in C#

By | 13 Feb 2007 | Article
Using ActiveX controls in Windows Forms applications using C#. NET.

Introduction

Recently, I has to use an ActiveX object (ThumbCtl class) and I had some problems with using an ActiveX control on a Windows Form.

Solution

You must consider that ActiveX controls can't be put directly on a Windows Form. For that, you have to do these steps:

  1. Generate wrapper assemblies for your ActiveX object. You can do this using the aximp.exe tool, e.g., aximp.exe c:\windows\system32\WEBVW.dll. Now you have generated two files: AxWEBVWLib.dll and WEBVWLib.dll.
  2. Add a reference to AxWEBVWLib.dll to your project.
  3. Now use your control like this:
  4. // Create new wrapper instance
    AxWEBVWLib.AxThumbCtl axctl = new AxWEBVWLib.AxThumbCtl();
    // Add object to specific window (control)
    mypanel.Controls.Add(axctl);
    // Set dock style
    axctl.Dock = DockStyle.Fill;
    // use OCX control methods (here we create thumbnail for our jpg file)
    axctl.displayFile(@"c:\temp\graphics.jpg");

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Rafal Ziolkowski

Software Developer (Senior)
Pareto PPN AS
Norway Norway

Member

Application Developer and Solutions Architect with many skills in programming languages and technolgies. Specializes in Microsoft .NET platform for last 6 years. Additionally Database Developer with wide experience in MySql, Microsoft SqlServer. Specializes in in building Workflow Software using LogicBase Studio from Transparent Logic (Now Altiris Workflow Solution). Lastly improve his skills in software development in Lotus Domino and Sharepoint. His primary goal is to improve skills in building Enterprise Architectures and Project Management.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generala msg from thanhtuu PinstaffSean Ewington3:57 10 May '07  
GeneralTerse. Pinmembernorm .net3:37 13 Feb '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 13 Feb 2007
Article Copyright 2007 by Rafal Ziolkowski
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid