我有个一个登陆的网页 你们元素比较简单 就2个输入框密码和账号 一个登陆按钮 
我现在在CHtmlView 如果操作给输入框赋值 并点击登陆按钮呢
麻烦大伙儿 讲下 我平时不怎么操作这个 现在急用

解决方案 »

  1.   

    并且知道框的id txtname txtpwd butdl
      

  2.   

    两种方法:一是通过调用js方法,你可以在你的程序中拼接JS,再使其在网页中执行
    二是通过获取到document接口,再通过其操作
      

  3.   

    //设置值
    void CTestInputDlg::SetElementValue(CString tagName,CString strValue,IHTMLDocument2* pDoc)
    {
    IDispatch* pElemDisp = NULL;
    IHTMLElement* pElem=NULL;
    IHTMLElementCollection* pElemColl = NULL;
    GetElementCollection(tagName,&pElemColl,pDoc); //获取指定TAG集合
    if(pElemColl!=NULL)
    {
    long length;
    pElemColl->get_length(&length); //指定TAG集合长度
    for (long i=0;i<length;i++)
    {
    _variant_t varBase(0);
    _variant_t varIndex(i);
    HRESULT hr = pElemColl->item(varIndex, varBase, &pElemDisp);
    if (SUCCEEDED(hr) && pElemDisp!=NULL)
    {
    hr = pElemDisp->QueryInterface(IID_IHTMLElement,(void**)&pElem);
    if(SUCCEEDED(hr) && pElem!=NULL)
    {
    BSTR bstrTemp;
    pElem->get_id(&bstrTemp);
    //pElem->
    CString tempStr(bstrTemp);
    MessageBox(tempStr);
    }
    pElemDisp->Release();
    }
    }
    }}