[webkit-dev] Managed C++ & Webkit

John Penman (jopenman) jopenman at cisco.com
Mon Oct 6 09:20:37 PDT 2008


Jason,

  Thanks for the reply.  I have tried to follow the WinLauncher example
and am able to get it working without any problems.  But if I try to
move into a new project that uses managed c++ (using Windows.Forms),
this is where my problems arise.  Below is the full code I am trying to
run, and it will work up until the initWithFrame call.  But I have
tracked it down to actually failing on the CoCreateInstance call, even
though no error is produced.  Since the object does appear to be created
(it has a handle), but none of the members to WebView exist.

 

//pin_ptr<IWebView*> p = &gWebView;

void* pInterface;

hr = CoCreateInstance(CLSID_WebView, 0, CLSCTX_ALL, IID_IWebView,
&pInterface);

if (FAILED(hr))

                goto exit;

                                                

gWebView = (IWebView*)pInterface;

 

gWebHost = new CPortalBrowserWebHost();

gWebHost->AddRef();

hr = gWebView->setFrameLoadDelegate(gWebHost);

if (FAILED(hr))

                goto exit;

 

HWND newHwnd = *(HWND *)&contentPanel->Handle;

 

hr = gWebView->setHostWindow((OLE_HANDLE) newHwnd);

if (FAILED(hr))

                goto exit;

 

RECT clientRect;

GetClientRect(newHwnd, &clientRect);

hr = gWebView->initWithFrame(clientRect, 0, 0);

if (FAILED(hr))

                goto exit;

                                                

static BSTR defaultURL = 0;

if(!defaultURL)

                defaultURL =
SysAllocString(TEXT("http://www.cisco.com"));
//"file://c://webresources//brand.html"

gWebView->setMainFrameURL(defaultURL);

 

gWebHost->loadURL(defaultURL);

 

Thanks again.

 

From: Jason Hullinger [mailto:sshjason at gmail.com] 
Sent: Monday, October 06, 2008 11:13 AM
To: John Penman (jopenman)
Cc: webkit-dev at lists.webkit.org
Subject: Re: [webkit-dev] Managed C++ & Webkit

 

I think the thing you are missing is calling
gWebView->setFrameLoadDelegate. See WinLauncher for more details on that
part.

Hope that helps at all. Are you trying to make this without a GUI? I've
personally had no luck with COM, althought I have had success with
Cocoa/OS X to some degree.

~/Jason Hullinger

On Mon, Oct 6, 2008 at 8:35 AM, John Penman (jopenman)
<jopenman at cisco.com> wrote:

Hi All,

  I am working on a project in VC 2005 in a managed environment.  I have
tracked down my issue of not getting WebKit working to this one function
call.  Has anyone had any experience getting it to work in a managed
environment?

 

pin_ptr<IWebView*> p = &gWebView;

hr = CoCreateInstance(CLSID_WebView, 0, CLSCTX_ALL, IID_IWebView, &p);

 

Ive also tried:

 

void* pInterface;

hr = CoCreateInstance(CLSID_WebView, 0, CLSCTX_ALL, IID_IWebView,
&pInterface);

 

gWebView = (IWebView*)pInterface;

 

In both cases, the object gets created but does not get instantiated.
All members of the object are unknown.

 

Thanks.


_______________________________________________
webkit-dev mailing list
webkit-dev at lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.webkit.org/pipermail/webkit-dev/attachments/20081006/3c20a8b3/attachment.html 


More information about the webkit-dev mailing list