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 Tools|Custom 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.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.74.205