How to host activex control for to render html on window using Visual c++ (x64) application

477 Views Asked by At

I am trying to render a html file in my own create window using Visual c++(x64). I have done every thing I just need some mechanism to display html file in my own window.I have html file contents stored in a buffer (and i am sure about that because i have the same html code in my buffer which I can see when I open that file in notepad, so the only thing i have to do is to get a way to render that html file in my window)

On a random search on google i have been aware that i need to host an activex control but i don't know how to do that.Yes ofcourse there are some samples availble on internet but they are not for Visual c++ (x64 MFC application).

What i have in mind is that (1.) i will create a dialog using-

     HINSTANCE   g_hInst2     = NULL;
                    m_hwndPreview= CreateDialogParam( g_hInst2,MAKEINTRESOURCE(IDD_HTML_DIALOG), m_hwndParent,(DLGPROC)DialogProc, (LPARAM)this);
        //I have not implemented the part below (its just idea that what should i do?? please correct me
// if my idea is wrong)I have not implemented it because when i create dialog using CreateDialogParam(...)  when i debug it i get m_hwndPreview=0000000000000 
                // and once if m_hwndPreview is done successfully i have assumed the code below in my
// mind to achieve my target. please correct me if i am wrong ??

                    CWebBrowser2 * pBrowse = (CWebBrowser2 *) GetDlgItem(IDC_EXPLORER1);
                    COleVariant sLoc("http://localhost");
                    pBrowse->Navigate2(sLoc, NULL, NULL, NULL, NULL);
            //after that
                if (SUCCEEDED(hr))
                {
                    ShowWindow(m_hwndPreview, SW_SHOW);
                    UpdateWindow( m_hwndPreview );
                }

Am i right ??

Please answer the two questions (1.) Why m_hwndPreview=00000000000 ?? because i have created a dialog(IDD_HTML_DIALOG) using resource editor and inserted a activex contol (Microsoft web browser) and it is done succesfully because i can see in my file resource.h (I have #define IDC_EXPLORER1 1046) so its sure that it has been done. There may be some problem in g_hInst2. i don't undersatnd it properly. (2.) Is my approach to achieve my target is correct ?? if i _hwndPreview is done succesfully then the code which i have assumed will work or not ?? is my approach correct ??

0

There are 0 best solutions below