HRESULT hr;
CComQIPtr< IHTMLElementCollection > spElementCollection;
hr = pIHTMLDocument2->get_all( &spElementCollection ); //取得表单集合
if ( FAILED( hr ) ) return ; long nFormCount=0; //取得表单数目
hr = spElementCollection->get_length( &nFormCount );
if ( FAILED( hr ) ) return ; for(long i=0; i<nFormCount; i++)
{
IDispatch *pDisp = NULL; //取得第 i 项表单
hr = spElementCollection->item( COleVariant(_T("acct_no")), COleVariant((long)0), &pDisp );
if ( FAILED( hr ) ) continue;
IHTMLControlElement* spFormElement=NULL;
        hr= pDisp->QueryInterface(IID_IHTMLControlElement, (void**)&spFormElement); 
pDisp->Release(); 
           if(FAILED(hr) || spFormElement==NULL) 
        {
AfxMessageBox("ere");//不为空
//return; 
          }
spFormElement->blur(); 
....

解决方案 »

  1.   

    首先看看HRSULT是什么样的错误,这个可以给出一定的信息。
    其次,接口的每个方法不一定都可以实现的。
    还有IHTMLControlElement,这是一个通用接口,你可以尝试用其表单所对应的具体控件的接口,比如是button的话,用buttonelement接口,或者直接用table中item接口,这个也有的。都尝试下。
      

  2.   

    对那个元素QI, IHTMLElement2
    IHTMLElement2::blur
      

  3.   

     升级SDK后,用IHTMLElement2,OK
    但是,如何,在不升级前正确使用呢