CHtmlView 给输入框赋值 我有个一个登陆的网页 你们元素比较简单 就2个输入框密码和账号 一个登陆按钮 我现在在CHtmlView 如果操作给输入框赋值 并点击登陆按钮呢麻烦大伙儿 讲下 我平时不怎么操作这个 现在急用 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 并且知道框的id txtname txtpwd butdl 两种方法:一是通过调用js方法,你可以在你的程序中拼接JS,再使其在网页中执行二是通过获取到document接口,再通过其操作 //设置值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(); } } }} 求解MFC关联SQL数据库的问题 VC2008怎么才能不用#include"stdafx.h" socket如何提交表单到https? 简单printf 在tree control中更改图标问题 win 9x下如何得进程的占用内存,cpu时间等信息啊? 刚才自己解决了一个困扰了好几天问题,高兴,散分~~~~ DLL MFC 初学者的问题:DAO是不是只能连Access? :想做一个WINDOWS下的程序员高手,学习流程该如何设定?? Clistctrl问题 求助,vc6编译的debug版总是异常,要不就new返回null,但release正常,用vc2008编译的则都正常
二是通过获取到document接口,再通过其操作
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();
}
}
}}