Tutorials
VB.NET 2005In this tutorial you will learn how to use ActiveX Control, the windows forms ActiveX Control Importer, Importing Controls with Toolbox, Using ActiveX Controls on Windows Forms and you will also learn how to use Platform Invoke.
As enterprises grow in strength and reach, IT challenges loom large. All enterprises are confronted with a multitude of legacy applications that are not scaleable or in line with the applications being created for the new environment. However, these applications cannot be thrown out for various reasons. They have to be migrated and made compatible with the current set of applications being created to exploit the use of the Internet, e-commerce, the extranet and other new technologies. The .NET framework provides the foundation for creating a Legacy Application Interface solution using Microsoft technologies. The effort is to make the potential of distributed computing a reality. Developers can focus upon the business logic while the .NET framework tools take care of the details of formatting, transporting data and so on.
In this lesson we shall focus on how legacy code is to be handled in Visual Basic.NET 2.0 BETA within the .NET Framework.
Windows Forms ActiveX Control Importer (Aximp.exe) is used to convert the type definitions in a COM type library for an ActiveX control into a Windows Forms control. Windows Forms are designed to host Windows Forms controls, namely the classes that are derived form System.Windows.Forms.Control. To facilitate the use of the ActiveX controls to be used in Windows Forms, Aximp.exe generates a wrapper class for an ActiveX control that can be hosted on a Windows Forms Controls. This will generate a wrapper control that derives from System.Windows.Forms.AxHost. This wrapper control has an instance of the underlying ActiveX control. It has knowledge of the ways to communicate with the ActiveX control methods and events as those of the generated control. The usage of the tool is given below:
Aximp [options] [.dll file | .ocx file]
Some of the options that can be used with this tools and the description are given below:
CLR proxy form COM types:
Windows Forms proxy for ActiveX controls : Ax
In designing applications with Visual Studio, the ToolBox is a very useful facility. The Visual Basic.NET developer deals with a number of classes during the course of developing an application. Controls are created and components created are reused repeatedly. The .dll files are referenced for creating an instance of an object. These controls can also be imported into the ToolBar for drag and drop facility.
The ToolBar is seen in the screenshot shown below at the left hand side of the viewer.

The ToolBox can be kept floating or docked. It can be a tabbed document, visible or hidden. The tool bar also contains many groupings. Groupings can be added as and when needed by right-clicking the tool box and choosing the options add tab. Tabs can be added, deleted or renamed. They can be grouped according to categories.
Controls can be created ab initio or by extending from another control, form or User defined control. These controls will appear on the ToolBox when added to it.
The process is illustrated in the screen shot below. Right click on the Toolbox, Choose the option to be added by clicking on the ‘Choose items’ from the context sensitive menu.

The Choose Items DialogBox appears. All the controls available are displayed to the user for selection. The Browse button gives further access to the user to navigate to the location of controls (.dll) which are not displayed in the list. After importing to the application the control is automatically, such controls or components are made available on the ToolBox which can be consumed by dragging and dropping.
Next Page: ActiveX Controls and Legacy Code - Page 2