Posts

Showing posts from January, 2007

IHTMLFormElement::get_elements fails

Don't blow your head, you have this situation: you have a valid form element and you want to access its elements. IHTMLFormElement* pForm = ... one way to do it is by: HRESULT IHTMLFormElement::get_elements(IDispatch **p) and the code looks like the following: IDispatch * pDisp = NULL ; pForm -> get_elements (& pDisp ); IHTMLElementCollection * pFormColl = NULL ; HRESULT hr = pDisp -> QueryInterface ( IID_IHTMLElementsCollection , ( void **)& pFormColl ); but you get pFormColl having NULL value and hr = 0x80004002 which means The QueryInterface method did not recognize the requested interface. The interface is not supported. Google'ing it a bit you get plenty of similar behaviour. The workaround is to use HRESULT IHTMLElement::get_children(IDispatch **p) The hint is given by MSDN description for this method: To access all elements contained in a form, call QueryInterface on IHTMLFormElement and request an IHTMLElement interface. Use the IHTMLElement::chi