Hi,

I'm trying to embed gecko in a MFC-Application with VisualStudio 6.0
as compiler. I'm using gecko-sdk-win32-msvc-1.8.0.4 because this seems
to be linkable with VisualStudio 6.0. Newer sdk versions 1.9.0.x gave
me linker errors so I'm using now sdk version 1.8.0.4.

I want to use gecko as a render engine for XUL to provide a
configurable UserInterface to the MFC-Application.

After I have generated some missing header files with xpidl I have now
some almost working code which only fails when it comes to LoadURI
(most of it is a copy from the winembed example). It looks like this:

<code>
nsCOMPtr<nsIBaseWindow> m_cpBaseWindow;
nsCOMPtr<nsIWebBrowser> m_cpWebBrowser;
nsCOMPtr<nsIWebBrowserChrome> m_cpChrome;

// init gecko
nsresult rv = NS_InitEmbedding(nsnull, nsnull);

// Create a nsWebBrowser instance...
m_cpWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv);

// create xul screen chrome
CXulScreenChrome* pChrome = new CXulScreenChrome();
m_cpChrome = pChrome;
m_cpChrome->SetWebBrowser(m_cpWebBrowser);

// Give the WebBrowser a pointer to the embedding component which
// implements the callback interfaces.
rv = m_cpWebBrowser->SetContainerWindow((nsIWebBrowserChrome*)
m_cpChrome);
m_cpBaseWindow = do_QueryInterface(m_cpWebBrowser);

// Initialize the WebBrowser with a native parent window
// (ie. HWND on Win32). Replace 'nativeWindow' with a
// reference to an appropriate native resource...
CRect rect;
pWnd->GetClientRect(rect);
rv = m_cpBaseWindow->InitWindow(pWnd->GetSafeHwnd(), // Native window
                                                                  nsnull, // 
Always nsnull.
                                                                  rect.left, 
rect.top, rect.Width(), rect.Height());

// Create the child window for the WebBrowser.
rv = m_cpBaseWindow->Create();

nsCOMPtr<nsIWeakReference> cpListener = do_GetWeakReference
(static_cast<nsIWebProgressListener*>(pChrome));
rv = m_cpWebBrowser->AddWebBrowserListener(cpListener, NS_GET_IID
(nsIWebProgressListener));
rv = m_cpWebBrowser->AddWebBrowserListener(cpListener, NS_GET_IID
(nsISHistoryListener));

// load file
nsCOMPtr<nsIWebNavigation> cp_WebNav(do_QueryInterface
(m_cpWebBrowser));
rv = cp_WebNav->LoadURI(NS_ConvertASCIItoUTF16("file:///C:/XUL/
test.xul").get(),
                               nsIWebNavigation::LOAD_FLAGS_NONE,
                               nsnull,
                               nsnull,
                               nsnull);
</code>

The class CXulScreenChrome implements a bunch of interfaces:

 nsIWebBrowserChrome,
 nsIEmbeddingSiteWindow,
 nsIWebProgressListener,
 nsIInterfaceRequestor,
 nsISHistoryListener,
 nsISupportsWeakReference,
 nsIObserver,
 nsIContextMenuListener,
 nsITooltipListener

but it seems none of the according functions is ever called.

LoadURI always gives me the return value 0x805e000a
(NS_ERROR_CONTENT_BLOCKED) even if i load some simple html files. It
seems, every content is blocked. How do I unblock content? Or is there
something completely wrong with my code?

Thanks,
Rainer
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding

Reply via email to