如何使用Visual c + +(x64)应用程序托管activex控件以在窗口上呈现html

时间:2013-08-08 08:02:29

标签: winapi activex webbrowser-control web-hosting ihtmldocument2

我正在尝试使用Visual c + +(x64)在我自己的创建窗口中呈现一个html文件。我已经完成了所有我需要一些机制来在我自己的窗口中显示html文件。我将html文件内容存储在缓冲区中(我确信这是因为我在缓冲区中有相同的html代码,我可以看到我在记事本中打开该文件,所以我唯一要做的就是找到一种方法在我的窗口中呈现该html文件)

在谷歌上的随机搜索我已经知道我需要主持一个activex控件但我不知道该怎么做。是的当然有一些样本在互联网上可用,但它们不适用于Visual c + +(x64 MFC应用)。

我的想法是 (1.)我将使用 -

创建一个对话框
     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 );
                }

我是对的?

请回答这两个问题(1.)为什么m_hwndPreview = 00000000000 ??因为我已经使用资源编辑器创建了一个对话框(IDD_HTML_DIALOG)并插入了一个activex控制器(Microsoft Web浏览器)并且它已成功完成,因为我可以在我的文件resource.h中看到(我有#define IDC_EXPLORER1 1046)所以它确定它已经完成了。 g_hInst2中可能存在一些问题。我没有正确地理解它。 (2.)我实现目标的方法是否正确?如果我成功完成_hwndPreview那么我假设的代码是否有效?我的方法是正确的吗?

0 个答案:

没有答案