本帖最后由 liuenhai211 于 2009-07-27 12:10:36 编辑

解决方案 »

  1.   

    还有一个问题,在调用js代码的时候,参数为一个对象,参数怎么传递
    //调用javascript
    CComVariant CDataImportDlg::ExecJavascript(const CString strFunc,
                                      const CStringArray& paramArray,IHTMLDocument2 *pIHTMLDocument2)
    {
    .........
    }
    以上代码就是在网上找的,关于js参数为CStringArray& paramArray 但是我的js是需要一个对象,不知道这个参数该怎么写function doBlur(obj){

    alert(obj.value);
    return;
    }
      

  2.   

    出什么错?
    函数参数的类型是IDispatch么?
      

  3.   

    提示错误信息"the   value   of   ESP   was   not   properly   saved   across   a   funciton   call.This   is   usually   a   result   of   calling   a   function   declared   with   one   call   convention   with   a   functioin   pointer   declared   with   a   different   calling   convention".   
      

  4.   

    【函数参数的类型是IDispatch么?】哪个参数?
      

  5.   

    function doBlur(obj){alert(obj.value);
    return;
    } 有方法和属性的要实现IDispatch……
      

  6.   

    这个是js函数,<INPUT class=Edit id=GMSFZHM onblur=doBlur(this) 
          maxLength=18 name=GMSFZHM fieldname="GMSFZHM" kind="idcard" must="true" 
          showInput="false" birthdate="CSRQ" sex="XB" rkbm="RKBM" rkname="XM" 
          rksfzh="GMSFZHM">
      

  7.   

    有msn吗?我的[email protected]
    多谢。
      

  8.   

    我问的是其实是一个问题。
    <INPUT class=Edit id=GMSFZHM onblur=doBlur(this) 
          maxLength=18 name=GMSFZHM fieldname="GMSFZHM" kind="idcard" must="true" 
          showInput="false" birthdate="CSRQ" sex="XB" rkbm="RKBM" rkname="XM" 
          rksfzh="GMSFZHM">
    function doBlur(obj){ alert(obj.value); 
    return; 
    } 我想在VC中控制执行onblur事件,但是出错,给input执行blur和直接给这个input设置focus出现一样的错误
    提示错误信息"the  value  of  ESP  was  not  properly  saved  across  a  funciton  call.This  is  usually  a  result  of  calling  a  function  declared  with  one  call  convention  with  a  functioin  pointer  declared  with  a  different  calling  convention". 然后我就想变个方法,直接在VC中调用doBlur这个js,从网上找执行的方法
    CComVariant CDataImportDlg::ExecJavascript(const CString strFunc, 
                                      const CStringArray& paramArray,IHTMLDocument2 *pIHTMLDocument2) 

    ......... 

    由于doBlur的参数是当前input控件,而这个函数的参数是CStringArray类型,所有不知道应该怎么传这个参数。
    不知道我说的是否明白。。多谢,多谢。
      

  9.   

    你应该传递一个IDispatch给doBlur,这个IDispatch应该是onblur=doBlur(this)这里this指向的元素的接口,也就是Input元素。
      

  10.   

    ---你应该传递一个IDispatch给doBlur,这个IDispatch应该是onblur=doBlur(this)这里this指向的元素的接口,也就是Input元素。不好意思,刚刚开始接触这里的知识,不知道该怎么写,能有更具体点的资料吗执行的方法
    hResult   =   pScript-> Invoke 
    (pDISPID,   IID_NULL,   0,   DISPATCH_METHOD,   &pDISPPARAMS,   &pCComVariant,   &pEXCEPINFO,   &nintArgErr); 
      

  11.   

    IHTMLDocument4::fireEvent 
    直接执行脚本也可以。
      

  12.   

    下面这种写法有什么错误吗?
    for(long i=0; i <nFormCount; i++) 

    IHTMLElement  *pElem  =  NULL; 
    hr = spElementCollection->item( CComVariant( i ), CComVariant(),  (LPDISPATCH*)&pElem); 
    CComQIPtr <IHTMLControlElement>  pCtrlElem(pElem); 
      if(pCtrlElem!=NULL) 
      { 
      pCtrlElem->focus(); 
      } } 
      

  13.   

    蒋老大,能不能给俺个小例子,能让一个input获得焦点或者能执行这个input的onblur事件。
    刚刚接触,知道的太少了
      

  14.   

    (LPDISPATCH*)&pElem这里有问题
    应该声明一个IDispatch指针,等item返回之后用QueryInterface获得其他接口
      

  15.   

    HRESULT   result   =   NULL; 
    IDispatch*   pdispatch   =   NULL; 
    IHTMLControlElement*   pcontrol   =   NULL;  pHtml-> item(COleVariant(name),   COleVariant((long)0),   &pdispatch); 
    result   =   pdispatch-> QueryInterface(IID_IHTMLControlElement,   (void**)&pcontrol); 
    pdispatch-> Release(); 
    if(FAILED(result)   ||   pcontrol==NULL) 
    return; 
    pcontrol->put_tabIndex(1);
    pcontrol->blur();
    pcontrol-> Release();  pHtml-> Release(); 我这样写还是同样的问题啊
      

  16.   

    找到问题了,用.net 2003编译执行就正常了,用vc6.0编译执行就出错。
    有哪位同学知道原因。
      

  17.   

    你是代码用了2003的一些东西。VC6没有。你在哪copy的代码自己应该知道的。
      

  18.   

    我查msdn也没有特别提到,而且VC6下也有blur事件
      

  19.   

    --你是代码用了2003的一些东西。VC6没有
    你说的是blur在VC6下没有吗?