我定义了:
CWebBrowser2 m_internetexplorer;对于打开的网页,我想查找其中特定的文本,
是用m_internetexplorer.GetDocument()吗?
该怎么使用啊?我这样的不行呃...void CMyWebDlg::OnFindtext()
{
// TODO: Add your command handler code here
if(m_internetexplorer.GetDocument()==(IDispatch *)"控件")
MessageBox("OK");
else
MessageBox("NO");}
但是结果是,明明打开的网页上有"控件"两个字,却仍然提示"NO",
不知道这样做对吗?希望高手们能给点指点啊~~
谢谢!
CWebBrowser2 m_internetexplorer;对于打开的网页,我想查找其中特定的文本,
是用m_internetexplorer.GetDocument()吗?
该怎么使用啊?我这样的不行呃...void CMyWebDlg::OnFindtext()
{
// TODO: Add your command handler code here
if(m_internetexplorer.GetDocument()==(IDispatch *)"控件")
MessageBox("OK");
else
MessageBox("NO");}
但是结果是,明明打开的网页上有"控件"两个字,却仍然提示"NO",
不知道这样做对吗?希望高手们能给点指点啊~~
谢谢!
解决方案 »
- 怪事,为什么有一个项目里面不能命中断点?
- 奇怪了,为何我按VK_LEFT进不了中断
- ★★★★★VC中调用WORD问题★★★★★
- ******************两个菜鸟问题************
- 在Dialog中根据Edit box 和Slider得变化随时改变显示的参数值怎么搞?
- 顺利通过毕业设计检查,高兴,散分(2)
- 请看!删除多列的怪问题
- 关于TCP,UDP断开连接的问题
- 请问在vc下一般用什麽开发程序?是application wizard ,mfc wizard 还是什麽?
- 问题很简单,我给30分
- 我是被lpDrawItemStruct->itemData 搞风了
- CListCtrl 数据更新了怎么显示不出来?
<input type="text" name="myName" value="控件" maxlength="15">
代码如下:
CComQIPtr<IHTMLDocument2,&IID_IHTMLDocument2> spHTML=NULL;
CComQIPtr< IHTMLElementCollection > spElementCollection;
CComPtr< IDispatch > spDisp;
CComQIPtr < IHTMLInputTextElement > spInputText;
//CComQIPtr < IHTMLInputButtonElement > spInputButton;
//CComQIPtr < IHTMLInputHiddenElement > spInputHidden;
//......spHTML = m_ctrlWeb.GetDocument();
if(spHTML)
{
spHTML->get_all(&spElementCollection);
if(spElementCollection)
{
spElementCollection->item(CComVariant(CComBSTR("myName")),CComVariant(),&spDisp);
spInputText = spDisp;
if(spInputText)
{
CComBSTR val;
spInputText->get_value(&val);
CString sVal = OLE2A(val.bstrVal);
if(sVal=="控件")
MessageBox("OK");
else
MessageBox("NO");
}
}
}
#include "Atlbase.h"
#include <mshtml.h>void CRefreshWebDlg::OnFindtext()
{
// TODO: Add your command handler code here CComQIPtr <IHTMLDocument2,&IID_IHTMLDocument2> spHTML=NULL; //335行error
CComQIPtr < IHTMLElementCollection > spElementCollection;
CComPtr< IDispatch > spDisp;
CComQIPtr < IHTMLInputTextElement > spInputText;
//CComQIPtr < IHTMLInputButtonElement > spInputButton;
//CComQIPtr < IHTMLInputHiddenElement > spInputHidden;
//...... spHTML = m_internetexplorer.GetDocument();
if(spHTML)
{
spHTML->get_all(&spElementCollection);
if(spElementCollection)
{
spElementCollection->item(CComVariant(CComBSTR("myName")),CComVariant(),&spDisp);
spInputText = spDisp;
if(spInputText)
{
CComBSTR val;
spInputText->get_value(&val);
CString sVal = OLE2A(val.bstrVal); //355行error
if(sVal=="控件")
MessageBox("OK");
else
MessageBox("NO");
}
}
}}
Compiling...
RefreshWebDlg.cpp
E:\VC++\FindWeb\FindWebDlg.cpp(335) : error C2440: 'initializing' : cannot convert from 'const int' to 'class ATL::CComQIPtr<struct IHTMLDocument2,&struct _GUID const IID_IHTMLDocument2>'
No constructor could take the source type, or constructor overload resolution was ambiguousE:\VC++\FindWeb\FindWebDlg.cpp(355) : error C2065: '_lpw' : undeclared identifier
E:\VC++\FindWeb\FindWebDlg.cpp(355) : error C2039: 'bstrVal' : is not a member of 'CComBSTR'
c:\program files\microsoft visual studio\vc98\atl\include\atlbase.h(3889) : see declaration of 'CComBSTR'
E:\VC++\FindWeb\FindWebDlg.cpp(355) : error C2065: '_convert' : undeclared identifier
Error executing cl.exe.RefreshWeb.exe - 4 error(s), 0 warning(s)这个会是哪里错了呢?
谢谢了啊!