In a few cases you might need to get a reference to the actual ActiveX control wrapped in a class generated by AxWrapperGen. This might be necessary, for example, when invoking a method that takes the ActiveX control as an argument.
All the wrapper classes inherit indirectly from System.Windows.Forms.AxHost, which represents the host for an ActiveX control on a .NET form. This class exposes the GetOcx method, which returns the reference in question.
You can use this technique both for the wrapper classes generated with AxWrapperGen and the VB6DataGrid, VB6MSChart, VB6MSHFlexGrid, VB6MMControl, and VB6Calendar (defined in VB Migration Partner’s support library):
Dim activeXcontrol As Object = myDataGrid.GetOcx()
The following VB6 code shows how you can use the ReplaceStatement pragma to have the replacement performed automatically when passing the ActiveX control to an external method:
Dim extObj As New ExternalLibrary.OcxHelpers