IHTMLDocument2 *pIHTMLDocument2 = NULL;
pIHTMLDocument2 = (IHTMLDocument2*)m_WebB.GetDocument();
//EnumFrame( pIHTMLDocument2 );//递归枚举当前 IHTMLDocument2 上的子框架framHRESULT hr;
CComBSTR bstrTitle;
pIHTMLDocument2->get_title( &bstrTitle );//取得文档标题USES_CONVERSION;bool bSub = FALSE;
CString strTitle =OLE2CT(bstrTitle);CComQIPtr< IHTMLElementCollection > spElementCollection;
hr = pIHTMLDocument2->get_forms( &spElementCollection );//取得表单集合
if ( FAILED( hr ) )
{
allInfo+="获取表单的集合 IHTMLElementCollection 错误\r\n";
return;
}long nFormCount=0;//取得表单数目
hr = spElementCollection->get_length( &nFormCount );
if ( FAILED( hr ) )
{
allInfo+="获取表单数目错误\r\n";
return;
}for(long i=0; i<nFormCount; i++)
{
IDispatch *pDisp = NULL;//取得第 i 项表单
hr = spElementCollection->item( CComVariant( i ), CComVariant(), &pDisp );
if ( FAILED( hr ) )continue;
CComQIPtr< IHTMLFormElement > spFormElement = pDisp;
pDisp->Release();
long nElemCount=0;//取得表单中 域 的数目
hr = spFormElement->get_length( &nElemCount );
if ( FAILED( hr ) )continue;
for(long j=0; j<nElemCount; j++)
{
/************************************************************************/
/* 以下这部分,谢谢,只需要可以找到 */
/************************************************************************/
IHTMLInputTextElement pPwdElement;
HRESULT hr = spFormElement->QueryInterface(IID_IHTMLInputTextElement,(void**)&pPwdElement);
if(SUCCEEDED(hr))
{
CComBSTR type;
pPwdElement->get_name(&type);
CString strType = OLE2CT(type);
MessageBox(strType);
}
}
//想提交这个表单吗?删除下面语句的注释吧
//spFormElement->submit();
}
pIHTMLDocument2 = (IHTMLDocument2*)m_WebB.GetDocument();
//EnumFrame( pIHTMLDocument2 );//递归枚举当前 IHTMLDocument2 上的子框架framHRESULT hr;
CComBSTR bstrTitle;
pIHTMLDocument2->get_title( &bstrTitle );//取得文档标题USES_CONVERSION;bool bSub = FALSE;
CString strTitle =OLE2CT(bstrTitle);CComQIPtr< IHTMLElementCollection > spElementCollection;
hr = pIHTMLDocument2->get_forms( &spElementCollection );//取得表单集合
if ( FAILED( hr ) )
{
allInfo+="获取表单的集合 IHTMLElementCollection 错误\r\n";
return;
}long nFormCount=0;//取得表单数目
hr = spElementCollection->get_length( &nFormCount );
if ( FAILED( hr ) )
{
allInfo+="获取表单数目错误\r\n";
return;
}for(long i=0; i<nFormCount; i++)
{
IDispatch *pDisp = NULL;//取得第 i 项表单
hr = spElementCollection->item( CComVariant( i ), CComVariant(), &pDisp );
if ( FAILED( hr ) )continue;
CComQIPtr< IHTMLFormElement > spFormElement = pDisp;
pDisp->Release();
long nElemCount=0;//取得表单中 域 的数目
hr = spFormElement->get_length( &nElemCount );
if ( FAILED( hr ) )continue;
for(long j=0; j<nElemCount; j++)
{
/************************************************************************/
/* 以下这部分,谢谢,只需要可以找到 */
/************************************************************************/
IHTMLInputTextElement pPwdElement;
HRESULT hr = spFormElement->QueryInterface(IID_IHTMLInputTextElement,(void**)&pPwdElement);
if(SUCCEEDED(hr))
{
CComBSTR type;
pPwdElement->get_name(&type);
CString strType = OLE2CT(type);
MessageBox(strType);
}
}
//想提交这个表单吗?删除下面语句的注释吧
//spFormElement->submit();
}
解决方案 »
- CreateProcess函数最后一个参数如果是NULL,那么就会导致运行时错误,为何?
- 从摄像头获取场景并显示时, 显示时, 帧速度很慢
- MS DataGrid怎样解决在无vc环境下运行?谢谢!
- 怎么在access数据库中,把表名字满足某个特定条件的表挑出来
- 点击确定按钮,改变确定按钮和取消按钮的字体大小,为什么总是出错?
- 不用记时器和多线程,怎样使滑棒控件随歌曲走动呢?
- ~~~该如何读取ACCESS数据库的“备注型”字段??
- 急!关于毕业设计的,这星期要完成.谁能解决我的问题,一定送分(100)!
- 一个简单的c++程序,请指教,在线等
- 各高手小菜问题
- 关于ClassView一点的问题?!
- 一个获取UDP发送端IP和端口的问题.VC MFC
就是源码里最后一段,就几行,谢谢了:)
form不是input,不支持IHTMLInputTextElement
你怎么不枚举form内的input了?
...//得到 pDoc2实际的指针IHTMLDocument3* pDoc3=NULL;
pDoc2->queryinterface(IID_IHTMLDocument3,(void **)&pDoc3);IHTMLElement* pElem=NULL;
pDoc3->getElementById("你的元素ID",(IHTMLElement **)&pElem);IHTMLInputTextElement* pInpTx=NULL;
pElem->queryinterface(IID_IHTMLInputTextElement,(void **)&pInpTx);总之,IE DOM的编程模型和Javascript其实是一样的。
for(long i=0; i<nFormCount; i++)
{
IDispatch *pDisp = NULL;//取得第 i 项表单
hr = spElementCollection->item( CComVariant( i ), CComVariant(), &pDisp );
if ( FAILED( hr ) )continue;CComQIPtr< IHTMLFormElement > spFormElement = pDisp;
pDisp->Release();long nElemCount=0;//取得表单中 域 的数目
hr = spFormElement->get_length( &nElemCount );
if ( FAILED( hr ) )continue;for(long j=0; j<nElemCount; j++)
{
/************************************************************************/
/*以下这部分,谢谢,只需要可以找到 */
/************************************************************************/
IDispatch *pDisp = NULL;//--------------取得表单内第 i 项的元素
hr = spElementCollection->item( CComVariant( i ), CComVariant(), &pDisp );
if ( FAILED( hr && !pDisp) )continue;IHTMLInputTextElement pPwdElement;
HRESULT hr = pDisp ->QueryInterface(IID_IHTMLInputTextElement,(void**)&pPwdElement);
pDisp->Release();
if(SUCCEEDED(hr))
{
CComBSTR type;
pPwdElement->get_name(&type);
CString strType = OLE2CT(type);
MessageBox(strType);
pPwdElement->Release();
}
}
/*以下这部分,谢谢,只需要可以找到 */
/************************************************************************/
IDispatch *pDisp = NULL;//--------------取得表单内第 i 项的元素
hr = spFormElement->item( CComVariant( i ), CComVariant(), &pDisp );
if ( FAILED( hr && !pDisp) )continue;