winapi - how to host html control in my window using a buffer which contents a html file -


i developing visual c++ applicatio(x64). trying suppose have html file in window explorer(i mean file file extension ".html"). when single click on preview on preview pane(so don't need open file can see file in preview pane on single click file).

i have developed similar type of application in case when click on "html file" code of html file in preview pane(the code can see if open html file in notepad). not expected happen want have preview of "html file" not code of html file.

i think need host browser control transform html code in preview pane display of html file(if correct ???) how ??

here code that-

    ihtmldocument2  * pdoc=null;     hresult hr2 = cocreateinstance(clsid_htmldocument, null, clsctx_inproc_server, iid_ihtmldocument2, (lpvoid *) &pdoc);     if (pdoc)     {         ipersiststreaminit *ppersist = null;         pdoc->queryinterface(iid_ipersiststreaminit,(lpvoid *) &ppersist);         if (ppersist)         {             imarkupservices *pms = null;             ppersist->initnew();             ppersist->release();             pdoc->queryinterface(iid_imarkupservices,(lpvoid *) &pms);             if (pms)             {                 imarkupcontainer *pmc = null;                 imarkuppointer *pmkstart = null;                 imarkuppointer *pmkfinish = null;                 pms->createmarkuppointer(&pmkstart);                 pms->createmarkuppointer(&pmkfinish);                 pms->parsestring(htmlfilecontents,0,&pmc,pmkstart,pmkfinish);     //this htmlfilecontents buffer of olechar type  contains code of html file (the code see when open html file in notepad)                 if (pmc)                 {                     ihtmldocument2 *pnewdoc = null;                     pmc->queryinterface(iid_ihtmldocument,(lpvoid *) &pnewdoc);                     if (pnewdoc)                     {                         ihtmlelement *pbody;                         pnewdoc->get_body(&pbody);                         if (pbody)                         {                             bstr strtext;                             pbody->get_innertext(&strtext);                             hr = instance->createpreviewwindowforhtml(strtext); // function responsible displaying html file in window. can see definition below after code.                             sysfreestring(strtext);                             pbody->release();                         }                         pnewdoc->release();                     }                     pmc->release();                 }                 if (pmkstart)                     pmkstart->release();                 if (pmkfinish)                     pmkfinish->release();                 pms->release();                 pms->release();             }         }         pdoc->release();     }     return true;   , function defintion of createpreviewwindowforhtml() below-     createpreviewwindowforhtml(pcwstr pszrtfwide) {     assert(m_hwndpreview3 == null);     hresult hr = e_fail;      if (m_hwndpreview3 == null)     {         hresult hr5 = hresult_from_win32(getlasterror());     }      if (m_hinsteditlibrary == null)     {         // msftedit_class used below comes binary         m_hinsteditlibrary = loadlibraryw(l"msftedit.dll");     }      if (m_hinsteditlibrary == null)     {         hr = hresult_from_win32(getlasterror());     }     else     {         // create preview window         hwnd pr = m_hwndpreview3 = createwindowexw(0, msftedit_class, null,             ws_child | ws_vscroll | ws_visible | es_multiline | es_readonly,  // create read-only             m_rcparent.left, m_rcparent.top, rectwidth(m_rcparent), rectheight(m_rcparent),             m_hwndpreview, null, null,null);         if (m_hwndpreview3 == null)         {             messageboxa(m_hwndpreview3,strerror(hr),"btn wnd2", mb_iconinformation);         }         else         {             int const cchrtf = 1 + wcslen(pszrtfwide);             pstr pszrtf = (pstr)cotaskmemalloc(cchrtf);             if (pszrtf)             {                 widechartomultibyte(cp_acp, 0, pszrtfwide, cchrtf, pszrtf, cchrtf, null, null);                 settextex st = { st_default, cp_acp };                  lresult hr4=sendmessage(m_hwndpreview3, em_settextex, (wparam) &st, (lparam) pszrtfwide);                 if (succeeded(hr4))                 {                     hr = adjustdialogpositionandsize();                     sendmessage(m_hwndpreview3, em_settextex, (wparam) &st, (lparam) pszrtfwide);                 }                   cotaskmemfree(pszrtf);                 hr = s_ok;             }             else             {                 hr = e_outofmemory;             }         }     }     return hr;  } 

any ideas why have html code in window ?? in code in order preview of html file in window rather html code ?? please tell me if doubts in understanding me ??

you have html code in window because choose richedit text renderer , text did not start "{\rtf".

if want html display, need html renderer instead of rich edit, mfc's chtmleditctrl. if don't want use mfc can write activex container host webbrowser control directly.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -