16,473
社区成员
发帖
与我相关
我的任务
分享
CString CHappyInternet70View::GetSelectText()
{
CString strName;
CString strText( " ");
try
{
::IHTMLDocument2 *pHTMLDoc;
::IHTMLSelectionObject *pSelObj;
::IHTMLTxtRange *pTxtRange;
LPDISPATCH pDisp = NULL;
pDisp = GetHtmlDocument();
pDisp-> QueryInterface(IID_IHTMLDocument2, (void**)&pHTMLDoc);
pHTMLDoc-> get_selection(&pSelObj);
pSelObj-> createRange((IDispatch**)&pTxtRange);
pTxtRange-> select();
BSTR bstrText,bstrName;
::IHTMLLocation *pLocation;
pHTMLDoc-> get_location(&pLocation);
pLocation-> get_hostname(&bstrName);
strName = _com_util::ConvertBSTRToString(bstrName);
pTxtRange-> get_text(&bstrText);
strText = _com_util::ConvertBSTRToString(bstrText);
SysFreeString(bstrName);
SysFreeString(bstrText);
return strText;
}
catch(...)
{
return strText;
}
}