-
September 23rd, 2012, 12:46 PM
#1
Help needed, to display the ATL windows in MFC View
Need an urgent help/ solution for the following issue for which I’m struggling for a week now.
Background:
I do have an ATL EXE which is creating a CAxHostWindow and then creating a CAxWindow as below:
HRESULT hr = CAxHostWindow::_CreatorClass::CreateInstance(
static_cast<IBrowserHost*>(this), IID_PPV_ARGS(&m_ptrUnkInner));
CBrowserHostWindowImpl::Create(hwndParent);
CAxWindow m_webBrowser;
CWindow& webBrowser = m_webBrowser;
webBrowser.Create(WC_STATIC, m_hWnd, rcClient, NULL, WS_CHILD | WS_VISIBLE);
HRESULT hr = E_FAIL;
CComQIPtr<IAxWinHostWindow> ptrWinHost = m_ptrUnkInner;
if(ptrWinHost)
{
hr = ptrWinHost->CreateControl(L"Shell.Explorer", m_webBrowser, NULL);
ATLASSERT(SUCCEEDED(hr));
}
if(SUCCEEDED(hr))
hr = HookUpWebBrowser();
Then function HookUpWebBrowser() is as below:
HRESULT BrowserHost::HookUpWebBrowser()
{
if(!IsWindow()) return E_FAIL;
CComQIPtr<IObjectWithSite> ptrObjWithSite;
HRESULT hr = m_webBrowser.QueryHost(&ptrObjWithSite);
ATLASSERT(SUCCEEDED(hr));
if(SUCCEEDED(hr))
{
hr = ptrObjWithSite->SetSite(static_cast<IBrowserHost*>(this));
ATLASSERT(SUCCEEDED(hr));
if(SUCCEEDED(hr))
{
const CWebBrowser2Ptr& ptrWB = GetWebBrowserPtr();
ATLASSERT(ptrWB != NULL);
hr = ptrWB->put_RegisterAsBrowser(VARIANT_TRUE);
ATLASSERT(SUCCEEDED(hr));
hr = DispEventAdvise(ptrWB);
ATLASSERT(SUCCEEDED(hr));
}
}
return hr;
}
Then finally I do Navigate to the given URL as below:
CComPtr<IWebBrowser2> ptrWebBrw;
ptrWebBrw->Navigate(m_url,NULL,NULL,NULL,NULL);
Everything is good and I’m able to host a window and navigate to the given URL from a MFC client, but in a separate window.
What I need is, instead of hosting a separate window for the ATL interface method call, I need to display the above ATL windows (from the ATL EXE) inside the MFC View window.
Is it possible to do ? If yes, then I would appreciate if you can provide me some sample code.
If not, is there any alternative way to do this?
I would really appreciate your quick response on this.
Thanks in advance,
SP42086
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
|