如果是CHtmlview的高手,进来看看。自制了浏览器,我想取得网页的名称,怎么做?

winmenaruto 2008-04-01 11:46:31
我是为了在我的浏览器中(基于CHtmlview),做一个简单收藏夹的功能,就是把当前的网址和网页的名称,写入到ini文件中。比如,我在maxthon中,把网页:“http://topic.csdn.net/t/20031212/13/2556726.html”加入收藏夹时,在网页名称中将显示:“---200分,如何取得链接所属的网页url和该链接名称----- VC-MFC - 基础类 - CSDN社区 community.csdn.net”。我现在就是想获得网页名称“200分,如何取得链接所属的网页url和该链接名称----- VC-MFC - 基础类 - CSDN社区 community.csdn.net”,请告诉我具体的获得方法。我知道strURL是当前网址,但是这个网站简介,不知道什么怎么获得了。
...全文
198 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
lion_wing 2008-04-07
  • 打赏
  • 举报
回复
汗!!!无语了!
lion_wing 2008-04-03
  • 打赏
  • 举报
回复
CHtmlview只是浏览网页的控件,他的标题是根据加载不同的页面而不同的,
根据CHtmlview得到所加载网页的IHTMLDocument2才能得到标题。
winmenaruto 2008-04-03
  • 打赏
  • 举报
回复
我想问问大家,一定要这么复杂才能获得网站名称吗?CHtmlview不是完整的实现了浏览网页的功能么?怎么连查看网站名称,这么基本的功能都没有??如果可以的话,我想通过CHtmlview来实现。
learnmfc 2008-04-03
  • 打赏
  • 举报
回复
其实可以读取临时文件里面的。
winmenaruto 2008-04-03
  • 打赏
  • 举报
回复
不能解决 因为vc 6里面根本没有这个函数
lion_wing 2008-04-03
  • 打赏
  • 举报
回复
我晕!你看看能不能解决你的问题,老大,别太形式化了。汗!!!
winmenaruto 2008-04-03
  • 打赏
  • 举报
回复
大哥你给的是VC 2005的msdn,不过还是谢谢你的热心。
lion_wing 2008-04-03
  • 打赏
  • 举报
回复
1、源文件应该有,那你就准备解析HTML吧
2、http://msdn2.microsoft.com/en-au/library/aa752635(VS.85).aspx
winmenaruto 2008-04-03
  • 打赏
  • 举报
回复
IHTMLDocument2::get_title(BSTR *p)在msdn里查不到啊,lion_wing
winmenaruto 2008-04-03
  • 打赏
  • 举报
回复
其实是这样的,我知道html的源文件都是放在临时文件里的,我要读出title,要现读出网页的源代码,而后从源代码中找出title,既然网页能够显示出来了,我能不能想办法读出已存在我电脑内的临时文件呢,即源代码??
还有,我用的是VC 6,网上说,都要自己写读title的函数的,你给我的函数,好像能直接获得title,但是msdn里面查不到,这怎么回事啊?
lion_wing 2008-04-02
  • 打赏
  • 举报
回复
mshtml.h
winmenaruto 2008-04-01
  • 打赏
  • 举报
回复
楼上的东西说的没头没脑,况且 ,我不需要网址,是网站名称
ruo_gu 2008-04-01
  • 打赏
  • 举报
回复
取得URL这样吧
m_pBrowserApp->get_LocationURL(&bstrUrl);
ruo_gu 2008-04-01
  • 打赏
  • 举报
回复
头文件:
#include <afxdhtml.h>
winmenaruto 2008-04-01
  • 打赏
  • 举报
回复
D:\webbrowser正确版\webbrowserView.cpp(187) : error C2065: 'IHTMLDocument2' : undeclared identifier
D:\webbrowser正确版\webbrowserView.cpp(187) : error C2065: 'pHtmlDoc2' : undeclared identifier
D:\webbrowser正确版\webbrowserView.cpp(187) : error C2059: syntax error : ')'
Generating Code...


要插入什么头文件??
ruo_gu 2008-04-01
  • 打赏
  • 举报
回复
IHTMLDocument2* pHtmlDoc2 = (IHTMLDocument2*)GetHtmlDocument();


winmenaruto 2008-04-01
  • 打赏
  • 举报
回复
不是很明白 我是继承CHtmlview的,IHTMLDocument2类怎么得到??
lion_wing 2008-04-01
  • 打赏
  • 举报
回复
先得到IHTMLDocument2
然后IHTMLDocument2::get_title(BSTR *p);
附:
IHTMLDocument2::title Property

Sets or gets the title of the document.

Syntax

HRESULT IHTMLDocument2::get_title(BSTR *p);
HRESULT IHTMLDocument2::put_title(BSTR v);

Parameters

p
Pointer to a variable of type BSTR that receives the title.
v
BSTR that specifies the title.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

The title identifies the contents of the document and is displayed in the header bar of the document window. This function sets or gets the TITLE object in the document header (defined by the HEAD object).
winmenaruto 2008-04-01
  • 打赏
  • 举报
回复
3楼的说了等于没有说 ,何止是半解,根本就说的我不解。
lion_wing 2008-04-01
  • 打赏
  • 举报
回复
get_Title

3,055

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC HTML/XML
社区管理员
  • HTML/XML社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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