首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

大家能帮小弟我翻译一下这个MFC函数是什么意思吗

2013-04-02 
大家能帮我翻译一下这个MFC函数是什么意思吗?就像帮我加注释一样,翻译一下它每步是在干什么,要实现个什么

大家能帮我翻译一下这个MFC函数是什么意思吗?
就像帮我加注释一样,翻译一下它每步是在干什么,要实现个什么功能?

BOOL CAssistFunction::CreateLink(IDispatch *pDisp,const char* szRefUrl)
{
IHTMLDocument2 *pDoc = (IHTMLDocument2*)pDisp;
if(pDoc)
{
IHTMLElementCollection *pAllColl;
pDoc-> get_all(&pAllColl);
long len=0;
HRESULT hr = pAllColl->get_length(&len);
if(S_OK != hr) return FALSE;
for (int i=0;i<len;i++)
{
VARIANT   vt; 
vt.vt   =   VT_I4; 
vt.lVal   =   i; 
IDispatch   *pDis; 
if(   S_OK   ==   pAllColl-> item(   vt,   vt,   &pDis   )   ) 

IHTMLDOMNode  *pNode   = NULL;
pDis->QueryInterface(&pNode);
if (pNode)
{
BSTR str;
pNode->get_nodeName(&str);
CString Node(str);
if (Node == _T("BODY") || Node == _T("body"))
{
CComBSTR tag("A");
IHTMLElement *pElem = NULL;
pDoc->createElement(tag,&pElem);
if (pElem)
{
IHTMLAnchorElement *pUrl = NULL;
pElem->QueryInterface(IID_IHTMLAnchorElement,(void**)&pUrl);
if (pUrl)
{
CString strUrl = szRefUrl;
BSTR strText = strUrl.AllocSysString();
pUrl->put_href(strText);
IHTMLDOMNode   *p   =  NULL; 
pElem->QueryInterface(&p);
if(   p   && pNode) 
{
IHTMLDOMNode   *pReturn; 
if(   S_OK   ==   pNode-> appendChild(   p,   &pReturn   )   ) 

Sleep(1000);
pElem->click();
pElem->Release();
::SysFreeString(strText);
return TRUE;
}
}
}
}
}
}
pDis->Release();
pDis = NULL;
}
}
}

[解决办法]
VC中使用IE控件 http://www.usidcbbs.com/read.php?tid=3962

热点排行