January 9th, 2003, 03:54 PM
access violation creating webbrowser2 control
i'm trying to add a webbrowser2 control to my app. i am receiving an 'access violation' when i attempt to create it. access violation is pointing to the following Cwnd function:
m_pCtrlCont = afxOccManager->CreateContainer(this);
my class definition and 'onupdate' function follows:
class CInitialWnd : public CWnd
int CInitialWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
if (CWnd::OnCreate(lpCreateStruct) == -1)
DWORD dwStyle = WS_VISIBLE | WS_CHILD;
m_target.Create(NULL, dwStyle, CRect(0, 0, 100, 100), this, ID_BROWSER_TARGET);
thanks in advance,
January 9th, 2003, 08:44 PM
Hi lordhairball !
Well, I know at least part of the issue here. But an important
thing is, there's really not much info in your post so I had to
make assumptions about what you did. I hope I'm right !
I assumed that you wrote your MFC part by hand and did not
use AppWizard to create the project.
The issue here is that the first thing that must be called when
using controls like this is AfxEnableControlContainer(), otherwise
the variable that is causing the crash is not initialized and you
won't have support for anything OLE.
Using a regular appwizard generated project wont display this
problem unless you remove some stuff from the settings that
are generated for you.
So in your app classes InitInstance call
Also, I don't think the control will be visible untill after you
Actually I know this so maybe I create it wrong !
And if I'm wrong I'm gonna be really embarassed
November 13th, 2013, 07:39 AM
Re: access violation creating webbrowser2 control
11 years later:
I have been trying to make an MFC OLE C++/CLI Wrapper for a C# User Control but had a problem with "Access Violation in InitControlContainer" when creating the managed control for several days now.
Your posts solved my problem.
Click Here to Expand Forum to Full Width