Get the DOM object in the webpage when OCX is initialized, and ocx initializes the dom object.
During OCX initialization, SetClientSite is called and the IOleClientSite object is passed in.
1 CComQIPtr <IOleControlSite, & IID_IOleControlSite> spSite (pClientSite); 2 CComDispatchDriver ecDisp; 3 spSite-> GetExtendedControl (& ecDisp );
Based on the IOleClientSite object, we can get the IOleControlSite object, and then get the DOM object of OCX in the webpage through the GetExtendedControl method of the IOleControlSite object.
Note: If you use javascript code createElement and appendChild to dynamically create OCX, you can call GetExtendedControl in SetClientSite of IE11 to obtain the object, however, the object cannot be obtained in IE9 (other versions are not tested ). How to dynamically create OCX allows SetClientSite to call GetExtendedControl to obtain the object. See my other article.