***200分,如何取得链接所属的网页url和该链接名称?****

myb123 2003-12-12 01:29:21
在FlashGet中可以做到,从IE中拖一个链接到FlashGet中,它能取得该链接所指向的url,
还能取到引用Referer(即该链接所属网页的url,例http://www.xxx//xxx.html),和能取到注释Comment(即该链接的名称,例如'点这里下载-> 本地下载')

而我用了网上某个类只能取到链接所指向的url,
请教,不知如何才能取得链接所属的网页url和该链接名称?
...全文
233 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
myb123 2003-12-13
  • 打赏
  • 举报
回复
谢谢
to jiangsheng(蒋晟.Net)
能贴点程序吗,我看不懂哎.
to yintongshun(踏雪有痕)
FlashGet在myie中也能取得链接所属的网页url和该链接名称,而myie的主窗口并不是IEFrame
myb123 2003-12-13
  • 打赏
  • 举报
回复
up
philis 2003-12-12
  • 打赏
  • 举报
回复
楼上的大哥,你贴的东西我找了好久都没找到,多谢了。
yintongshun 2003-12-12
  • 打赏
  • 举报
回复
让应用程序从IE中获取键入的网址
HWND hwnd=::FindWindow(_T("IEFrame"),NULL);
 if(hwnd)
 {
   HWND hwnd2=::FindWindowEx(hwnd,NULL,_T("Edit"),NULL);


char sz[255];
::SendMessage(hwnd2,WM_GETTEXT,255,(LPARAM)sz);
AfxMessageBox(sz);
 }

结果发现不能得到正确的结果,从SPY上看,类名也全部是正确的,为什么不能得到正确的结果呢?看了他的代码后,我进行了如下改动,就可以得到正确的结果了:

HWND hwnd=::FindWindow(_T("IEFrame"),NULL);
if(hwnd)
{
HWND hwnd2=::FindWindowEx(hwnd,NULL,_T("WorkerW"),NULL);
HWND hwnd3=::FindWindowEx(hwnd2,NULL,_T("ReBarWindow32"),NULL);
HWND hwnd4=::FindWindowEx(hwnd3,NULL,_T("ComboBoxEx32"),NULL);
HWND hwnd5=::FindWindowEx(hwnd4,NULL,_T("ComboBox"),NULL);
HWND hwnd6=::FindWindowEx(hwnd5,NULL,_T("Edit"),NULL);

char sz[255];
::SendMessage(hwnd6,WM_GETTEXT,255,(LPARAM)sz);
AfxMessageBox(sz);
}
}

下面是相关的:
IE编程技巧1.实现Ctrl+C:
ExecWB(OLECMDID_COPY,OLECMDEXECOPT_DONTPROMPTUSER,NULL,NULL);

2.实现Ctrl+V:

ExecWB(OLECMDID_PASTE,OLECMDEXECOPT_DONTPROMPTUSER,NULL,NULL);

3.实现查找:

MSHTML::IHTMLDocument2Ptr pdoc;
_variant_t varinput,varoutput;
IOleCommandTarget *pCmd;
HRESULT hr;
pdoc=GetHtmlDocument();
hr=pdoc.QueryInterface(IID_IOleCommandTarget,&pCmd);
if(SUCCEEDED(hr))
{
varinput=_T("");
hr=pCmd->Exec(&CGID_MSHTML,IDM_FIND,OLECMDEXECOPT_DODEFAULT,&varinput,&varoutput);
}

4.实现显示源程序:

MSHTML::IHTMLDocument2Ptr pdoc;
_variant_t varinput,varoutput;
IOleCommandTarget *pCmd;
HRESULT hr;
pdoc=GetHtmlDocument();
hr=pdoc.QueryInterface(IID_IOleCommandTarget,&pCmd);
if(SUCCEEDED(hr))
{
varinput=_T("");
hr=pCmd->Exec(&CGID_MSHTML,IDM_VIEWSOURCE,OLECMDEXECOPT_DODEFAULT,&varinput,&varoutput);
}

5.实现显示Internet选项:

MSHTML::IHTMLDocument2Ptr pdoc;
_variant_t varinput,varoutput;
IOleCommandTarget *pCmd;
HRESULT hr;
pdoc=GetHtmlDocument();
hr=pdoc.QueryInterface(IID_IOleCommandTarget,&pCmd);
if(SUCCEEDED(hr))
{
varinput=_T("");
hr=pCmd->Exec(&CGID_MSHTML,IDM_OPTIONS,OLECMDEXECOPT_DODEFAULT,&varinput,&varoutput);
}

6.下载事件说明:

OnDownloadBegin <--开始下载
OnDownloadComplete <--下载结束
OnDocumentComplete <--页面下载完毕

对于每个HTML页面,顺序都是如此.如果是Frame或IFrame的文件都会当成HTML页面处理.也就是说如果一个页面中有3个IFrame,那么总共会触发4次BeforeNavigate2事件.

对于每个连接且需要显示出来的二进制文件(如*.gif,*.bmp,*.jpg...)都会触发一个DownloadBegin和DownloadComplete事件.

那我们怎么判断是否全部下载完毕呢?嘿嘿,TWebBrowser控件不是有一个Busy属性的吗?

7.点击链接产生的事件:

OnBeforeNavigate2 <--开始链接时会触发此事件
OnNavigateComplete2 <--成功的链接到此网页(以后才会有上面的事件)


8.包括相关文件:

#include <mshtmhst.h>
#include <mshtmcid.h>//这里面有很多实现IE功能的XXID,请看一看!
#import <mshtml.tlb>





蒋晟 2003-12-12
  • 打赏
  • 举报
回复
The hyperlink object
A hyperlink object implements the IHlink interface and encapsulates four pieces of reference information: a moniker to the hyperlink target; a string for the location within the target; a friendly name for the target; and additional parameters.

The hyperlink object completely encapsulates the behavior of navigating to a referenced location. It also supports the ability to save and load itself through the IPersistStream interface, and the ability to be transferred through the clipboard or through drag-and-drop operations by means of IDataObject. A standard hyperlink object implementation is provided with the system, and it is not advisable to implement another version. A document can use the standard hyperlink object to represent hyperlinks within itself, thus encapsulating the work of navigating, saving, loading, dragging, dropping, cutting, and pasting hyperlinks. Standard hyperlink objects are created through the HlinkCreateFromData, HlinkCreateFromMoniker, HlinkCreateFromString, and OleLoadFromStream functions. The standard hyperlink object implements the IHlink, IPersistStream, and IDataObject interfaces.

IHlink::GetHlinkSite Method

The hyperlink container
A hyperlink container is a document or application that contains hyperlinks. The container supports hyperlinks by implementing the IHlinkSite interface and, if the container's objects can be targets of other hyperlinks, the IHlinkTarget interface.

Note Generally, an object that acts as a hyperlink container can also act as a hyperlink target. An HTML page, for example, can contain a number of hyperlinks to other pages, while at the same time it can be the target of hyperlinks from other HTML pages.
The hyperlink site
A hyperlink site is a COM object that implements the IHlinkSite interface and supplies either the moniker or interface identifier of its hyperlink container. One hyperlink site can serve multiple hyperlinks. The moniker supplied by the hyperlink site is used to evaluate relative monikers to the hyperlink target. If the relative moniker is NULL, the target of the link is in the same container object, and IHlink::Navigate can result in an efficient internal jump

Note The standard hyperlink object performs internal jumps by retrieving the container's IHlinkTarget moniker using IHlinkTarget::GetMoniker (which avoids an unnecessary moniker bind). The object then asks the container to navigate directly through the IHlinkTarget::Navigate method
popyyb 2003-12-12
  • 打赏
  • 举报
回复
up
warton 2003-12-12
  • 打赏
  • 举报
回复
to tjandy把代码贴上来看一下吧!
liwz123 2003-12-12
  • 打赏
  • 举报
回复
to tjandy(ANDY) :
能否法我一份,谢谢了
lwz_li888@sohu.com
myb123 2003-12-12
  • 打赏
  • 举报
回复
谢谢tjandy(ANDY)了,
我的e-mail是mincpu@163.net
tjandy 2003-12-12
  • 打赏
  • 举报
回复
我有代码,你把邮箱给我,我发给你
liwz123 2003-12-12
  • 打赏
  • 举报
回复
up

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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