读书人

初学提交表单请问这里的达人

发布时间: 2012-04-28 11:49:53 作者: rapoo

初学提交表单,请教这里的达人?

C/C++ code
void CChangeHtmlByMFCDlg::OnBnClickedButton2(){    // TODO: 在此添加控件通知处理程序代码    CString str;    GetDlgItem(IDC_EDIT)->GetWindowText(str);    //得到编辑框的字符串,放到百度输入框中    CComPtr < IDispatch > spDispDoc;    spDispDoc = m_WebOcx.get_Document();    CComQIPtr< IHTMLDocument2 > spDocument2 = spDispDoc;    CComQIPtr< IHTMLElementCollection > spElementCollection;//    HRESULT hr = spDocument2->get_forms( &spElementCollection );    if(SUCCEEDED(spDocument2->get_all(&spElementCollection)))    {        CComPtr<IDispatch> spDisp;        HRESULT hr;        hr = spElementCollection->item(CComVariant("wd"), CComVariant("0"), &spDisp);        if(SUCCEEDED(hr))        {                CComQIPtr<IHTMLInputElement>  spElem = spDisp;            spElem->put_value(CComBSTR(str));        }    }}


该函数的功能是,把程序中编辑框的文字放到百度首页的编辑框中。

奢求达人帮我一一解释第五行以后的语句,

[解决办法]
探讨

引用:
获取所有的HTML页面元素,然后匹配关键字得到对应的元素,然后设置数据


老师,大概的意思我理解,

spElementCollection->item(CComVariant("wd"), CComVariant("0"), &spDisp);

这句里面的CComVariant("wd"), CComVariant("0")……

读书人网 >VC/MFC

热点推荐