-
January 9th, 2003, 04:54 PM
#1
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:
BOOL CWnd::InitControlContainer()
{
m_pCtrlCont = afxOccManager->CreateContainer(this);
}
my class definition and 'onupdate' function follows:
class CInitialWnd : public CWnd
private:
CWebBrowser2 m_target;
int CInitialWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
DWORD dwStyle = WS_VISIBLE | WS_CHILD;
m_target.Create(NULL, dwStyle, CRect(0, 0, 100, 100), this, ID_BROWSER_TARGET);
return 0;
}
thanks in advance,
chris
-
January 9th, 2003, 09:44 PM
#2
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
AfxEnableControlContainer()
Also, I don't think the control will be visible untill after you
m_Browser.Navigate("Someplace");
Actually I know this so maybe I create it wrong !
And if I'm wrong I'm gonna be really embarassed
mdmd
-
November 13th, 2013, 08:39 AM
#3
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.
THANK YOU!
J
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|