问个关于webbrowse的问题

puyinghua 2005-03-19 02:35:15
1、请问webbrowse的方法与属性?(搜了下,没找到资料,惭愧)

2、在dephi里,用这控件打开一个网页中,可以用以下方法得到一个表中的值

eg: 得到表对象 m_webBrowse.oleobject.document.all.tags("table")

那么在VC中呢? 如果实现?
...全文
110 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzheng318 2005-03-20
  • 打赏
  • 举报
回复
帮楼主顶,关注!
oyljerry 2005-03-20
  • 打赏
  • 举报
回复
1,VC中有一个WebBrowser的控件,可以直接使用
2,通过IHTMLDocument2接口来操作
masterz 2005-03-20
  • 打赏
  • 举报
回复
#include <iostream>
#include <tchar.h>
#import <mshtml.tlb>
#import <shdocvw.dll>
void GetAllTablesInRunningIE()
{
// Import the following files in your stdafx.h
// #import <mshtml.tlb> // Internet Explorer 5
// Refer to "Connect to Internet Explorer Instances, From your own Process. " in www.codeguru.com
// enumeration all shell windows, you have to
//modify according your own need.
// masterz vc2003 windows2003 IE6
SHDocVw::IShellWindowsPtr m_spSHWinds;
if(m_spSHWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows)) == S_OK)
{
long nCount = m_spSHWinds->GetCount();
for (long i = 0; i < nCount; i++)
{
IDispatchPtr spDisp;
_variant_t va(i, VT_I4);
spDisp = m_spSHWinds->Item(va);
SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);
if (spBrowser != NULL)
{
IDispatchPtr pDispDoc;
if(spBrowser->get_Document(&pDispDoc) == S_OK && pDispDoc!= 0 )
{
MSHTML::IHTMLDocument2Ptr spHtmlDocument(pDispDoc);
if(spHtmlDocument == NULL)
continue;
MSHTML::IHTMLElementCollectionPtr pColl=NULL;
HRESULT hr=spHtmlDocument->get_all(&pColl);
if(pColl == NULL)
continue;
IDispatchPtr pDispCol = pColl->tags(_variant_t("table"));
MSHTML::IHTMLElementCollectionPtr pAllTables(pDispCol);
if(pAllTables)
{
std::cout<<"There are "<<pAllTables->Getlength()<<" in the document"<<std::endl;
}
}
}
}

}
else {
std::cout<<("Shell Windows interface is not available")<<std::endl;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
GetAllTablesInRunningIE();
CoUninitialize();
system("pause");
return 0;
}
jerry 2005-03-19
  • 打赏
  • 举报
回复
VC里操作COM接口,要实现相同的目的,要烦多了
Kudeet 2005-03-19
  • 打赏
  • 举报
回复
1 WebBrowser Control Overviews and Tutorials
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/browser_control_ovw_entry.asp
2 俺只知道应该是通过IHTMLDocument2接口来操作
http://dev.csdn.net/develop/article/28/28107.shtm
rabo 2005-03-19
  • 打赏
  • 举报
回复
VC里面有webbrowse2控件,拖进去就能用了。

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧