// IHTMLElement* pHtmlElement = NULL;
// if( SUCCEEDED(pElement->get_parentElement( &pHtmlElement ) )
// && pHtmlElement )
// {
// CComVariant varint(NULL);
// if( SUCCEEDED( pHtmlElement->getAttribute( L"itemData", 0, &varint ) ) )
// {
// RECORD* pRecord = (RECORD*)(LONG_PTR)_wtol( varint.bstrVal );
// if ( pRecord )
// {
// MessageBox( (pRecord->strContent +pRecord->strSender).c_str() );
// }
// }
// }
IHTMLElement* pParentElement;
pElement->get_parentElement(&pParentElement);
CComVariant varName;
CComBSTR bstr(_T("itemData"));
pParentElement->getAttribute(bstr,0,&varName);
MessageBox((_bstr_t)varName.bstrVal);
{
//如果网页已经初始化,则跳过
if ( !m_bInited )
{
__super::OnNavigateComplete( pDisp, szUrl );
m_bInited = true;
// 得到 IHTMLDocument2 指针
CComPtr< IHTMLDocument2 > spDoc;
GetDHtmlDocument( &spDoc );
if ( spDoc )
{
// 得到 IPersistStreamInit 指针
CComQIPtr< IPersistStreamInit, &IID_IPersistStreamInit > spPSI( spDoc );
// 申请内存,复制 HTML 字符串
if ( spPSI )
{
CHtmlEditer html;
CString Path;
CString strModuleName;
GetModuleFileName( NULL, strModuleName.GetBufferSetLength( MAX_PATH ), MAX_PATH );
strModuleName.ReleaseBuffer();
Path.Format( _T("res://%s/%d"), strModuleName, IDR_CSS_DIV );
//添加CS样式
html.AppendStyle( (LPCTSTR)Path );
//添加script脚本
html.AppendHead(SCRIPT_CODE);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define FOWARD "<div id=/"divid/" onmouseover=/"SetState(event,this,/'mouseover/')/" /
onmouseout=/"SetState(event,this,/'mouseout/')/"><img src = /"C://Documents and Settings//install.insTALL-31BE561//桌面//个人HTML、js及css测试程序//我的文件夹//a.bmp/" align = /"left/" class=/"alignTop/"><table class=/"tableT/"><tr id=/"trid/" class=/"trT/"><td itemData = /"%s/">%s/
<span class = /'visible/' id = /'ID_FROM/'>%s</span>/
<span class = /"visible/" id= /'ID_WHERE/'>%s</span><span class = /"hidden/" id= /'ID_REPLY/'>%s</span><span class = /"hidden/" id= /'ID_FORWAD/'>%s</span><span class = /"hidden/" id= /'ID_SOME/'>%s</span></td></tr><tr><td id=/'ID_CONTEXT/'>%s</td></tr></table></div>"
RECORD* pRecord = new RECORD;
pRecord->strContent = _T("test content");
pRecord->strSender = "12345678911";
CString strName = "刘德华";
CString tableHead = "30分钟前 来自G3通话客户端";
CString strClass = "|G3通话";
CString strContext = "来电, 已接";
CString strReply = "回复|";
CString strForward= "转发|";
CString strSome = "更多操作";
CString str;
str.Format(FOWARD,strName,strName,tableHead,strClass,strReply,strForward,strSome,strContext);
html.AppendBody(str.GetBuffer(0));
strName = "黎明";
tableHead = "30分钟前 来自G3通话客户端";
strClass = "|G3通话";
strContext = "来电, 未接";
strReply = "回复|";
strForward= "转发|";
strSome = "更多操作";
str.Format(FOWARD,strName,tableHead,strClass,strReply,strForward,strSome,strContext);
html.AppendBody(str.GetBuffer(0));
//将内容初始化到网页控件
std::string strHtml = html.toString();
LPTSTR lpMem = (LPTSTR)::GlobalAlloc( GPTR, (strHtml.length()+1)*sizeof(char) );
if ( lpMem )
{
lstrcpy( lpMem, strHtml.c_str() );
// 转换内存为流对象指针
CComPtr< IStream > spStream;
CreateStreamOnHGlobal( lpMem, TRUE, &spStream );
// 初始化后,装载显示
spPSI->InitNew();
spPSI->Load( spStream );
}
lpMem = NULL;
//m_pBrowserApp->Refresh();
}
}
}
}