请问DX,是否能够把通过IHTMLDocument2得到的网页里面的链接直接触发?

guti_milan 2006-09-11 05:42:38
我现在已经可以得到自己想要的链接
但是我如何在不用Naviagte2 等方法的同时触发他们呢
是否用get_click?
还是用其他
请帮帮忙!
谢了!!!!!!!!!!!
...全文
261 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lion_wing 2006-09-25
  • 打赏
  • 举报
回复
那就是你的代码有问题了
guti_milan 2006-09-14
  • 打赏
  • 举报
回复
是的
断点没有触发!
lion_wing 2006-09-12
  • 打赏
  • 举报
回复
IHTMLDocument2::open是打开一个窗口,并加载页面
IHTMLElement::click是指定的标记单击,当然可以在脚本中的链接标记onclick中,打开一个窗口,也可以做其它的处理。

guti_milan 2006-09-12
  • 打赏
  • 举报
回复
那兄台
IHTMLDocument2::open
和上面的方法有什么区别吗?
谢谢!
lion_wing 2006-09-12
  • 打赏
  • 举报
回复
你的意思是说if(hr == S_OK)这个条件成立了,
但GetMyLinks(0,67);这一行代码却不执行?
guti_milan 2006-09-12
  • 打赏
  • 举报
回复
click事件发生后
他的IHTMLDocument2指针是click触发的那个页面的指针吗?

还有

BOOL CGutiBrowserView::GetNextPageLinks(int s,int e)
{
IHTMLDocument2 *pDoc = NULL;
IHTMLElementCollection *pAllElem = NULL;
IHTMLElement *pElem = NULL;
// IHTMLAnchorElement *pAnchor = NULL;
// IHTMLElement *ptext = NULL;
long p;
// BSTR bstrSrc;
VARIANT name;
name.vt = VT_I4;
HRESULT hr;
// CLink *item;

try{
pDoc = (IHTMLDocument2*)(this->GetHtmlDocument());
if(pDoc!=NULL)
{
// m_LinkList.Clean();
pDoc->get_links(&pAllElem);
if(pAllElem!=NULL)
{
pAllElem->get_length(&p);
if(p>0)
{
//save all links
for(int i=s; i<e; i++)
{
name.lVal = i;
hr = pAllElem->item(name, name, (LPDISPATCH*)&pElem);
if(hr == S_OK)
{
if(pElem != NULL)
{
hr = pElem->click();
if (hr == S_OK)
{
GetMyLinks(0,67);

}
pElem->Release();
pElem = NULL;
}
}
}
}
}
}
}catch(...){}

try{
if(pDoc != NULL)
pDoc->Release();
if(pAllElem != NULL)
pAllElem->Release();
}catch(...){}

return TRUE;
}

我调试了
hr = pElem->click();也触发了
但是if(hr == S_OK)里面不执行!
不知道为啥!
兄台帮我看看,问题出在哪里?
lion_wing 2006-09-11
  • 打赏
  • 举报
回复
IHTMLElement::click Method

--------------------------------------------------------------------------------

Simulates a click by causing the onclick event to fire.

Syntax

HRESULT click(VOID);
Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks


Note Simulating a click using the IHTMLElement::click does not bring the element being clicked into focus. (See example below).

3,055

社区成员

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

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