none
dll中怎么创建一个带有Web Browser Control的窗口? RRS feed

  • 问题

  • dll中怎么创建一个带有Web Browser Control的窗口?我已经在Dll入口:

    AfxEnableControlContainer();

    BOOL bInit = AfxOleInit();

    现在窗口能显示启动!但是出现 

    Warning: AfxEnableControlContainer has not been called yet.
    >>> You should call it in your app's InitInstance function.

    这个错误!无法显示其上面Webbrowser control 

    请问有什么办法解决?

    2014年6月26日 6:27

全部回复

  • 你好,

    正如错误提示你的,你需要确保AfxEnableControlContainer 被调用。同时可以试一下CoInitialize 代替AfxOleInit。

    找到 class view, 右击你的 DLLApp class. 选择 Add Virtual Function->InitInstance->AddHandle->Ok 从而产生一个函数,在这个函数中插入如下代码:

    ------------------------------------------
    {
    // TODO: Add your specialized code here and/or call the base class

    AfxEnableControlContainer (); //INSERT THIS

    CoInitialize(NULL); //INSERT THIS

    return CWinApp::InitInstance();
    }
    -------------------------------------------
     但是一定要记得 uninitialize the instance, 仿照如上步骤添加一个函数,然后在函数中添加如下代码:
    -------------------------------------------
    {
    // TODO: Add your specialized code here and/or call the base class
    CoUninitialize(); //INSERT THIS

    return CWinApp::ExitInstance();
    }


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年6月30日 3:24
  •  这些已经做过尝试!但还出现如下问题!

    CoCreateInstance of OLE control {8856F961-340A-11D0-A96B-00C04FD705A2} failed.
    >>> Result code: 0x800401f0
    >>> Is the control is properly registered?

    2014年7月2日 18:01
  • 你好,

    你确定你调用了方法吗?如果你已经调用了这个还是出现这个问题,那你可以考虑再调用一下 AfxOleInitModule。

    http://msdn.microsoft.com/en-us/library/ttbdck38.aspx


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年7月4日 6:25