Importing ActiveX Controls into .NET

You can use your favorite ActiveX controls in .NET. The aximp.exe tool creates a wrapper around an ActiveX control that exposes the types of the ActiveX controls as members of a control that inherits from System.Windows.Forms.Control . The wrapper manages interactions between the client application and the wrapped ActiveX control. You can add an ActiveX control ( .ocx ) to the Toolbox from the ToolsCustom Toolbox menu. In the Custom Toolbox dialog, select the COM Components tab (which is selected by default), and check the ActiveX controls you want to import. The aximp.exe utility will run, creating a wrapper for the control and adding a reference to the wrapper control in the References section.

UsesActiveXControl.sln adds the Microsoft Web Browser control ( SHDocVw.dll ) and incorporates this control into a Windows Form. Figure 7.7 shows the Customize Toolbox with the ActiveX control selected. Figure 7.8 shows the control in the Toolbox, and Figure 7.9 shows a reference to the wrapper class in the References section of the Solution Explorer. (By convention the original ActiveX file name has an Ax prefix added; thus SHDocVw.dll is managed by the wrapper AxSHDocVw.dll .)

Figure 7.7. A selected ActiveX control in the Customize Toolbox.


Figure 7.8. The imported ActiveX control in the .NET Toolbox.


Figure 7.9. The ActiveX Interop wrapper assembly in the Solution Explorer.


Visual Basic. NET Power Coding
Visual Basic(R) .NET Power Coding
ISBN: 0672324075
EAN: 2147483647
Year: 2005
Pages: 215
Authors: Paul Kimmel © 2008-2017.
If you may any questions please contact us: