CAxWindow::QueryHost and CAxWindow::QueryControl return E_FAIL 
Author Message
 CAxWindow::QueryHost and CAxWindow::QueryControl return E_FAIL

#import "mshtml.tlb"
MSHTML::IHTMLDocument2Ptr m_htmlDoc;

 HGLOBAL res = LoadResource(_Module.m_hInstResource,
FindResource(_Module.m_hInstResource, MAKEINTRESOURCE(IDH_FORM), RT_HTML));
 if(!res)return -1;
 m_wndView.Create(m_hWnd, rcClient, (LPCTSTR)LockResource(res),
    WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);

m_wndView.QueryControl(&m_htmlDoc);

the last line returned E_FAIL. But the MSHTML control will be displayed
without any problem(I can see the HTML in IDH_FORM)

Another approach:

m_htmlDoc.CreateInstance(CLSID_HTMLDocument);
CComQIPtr<IPersistStreamInit> spPSI = m_htmlDoc;
spPSI->InitNew();

CComPtr<IAxWinHostWindow> spHost;
m_wndView.QueryHost(IID_IAxWinHostWindow, (void**)&spHost);
spHost->AttachControl(m_htmlDoc, m_wndView);

m_htmlDoc->body->innerHTML = _bstr_t((LPCTSTR)LockResource(res));

This approach also failed because QueryHost() returned E_FAIL and
spHost.p was NULL.

Please help me! Thanks.



Wed, 05 Nov 2003 17:57:54 GMT  
 CAxWindow::QueryHost and CAxWindow::QueryControl return E_FAIL
I forgot to say that IDH_FORM is a text resource like this:
MSHTML:<html>aaaaaaaa</html>

Thanks.


Quote:
> #import "mshtml.tlb"
> MSHTML::IHTMLDocument2Ptr m_htmlDoc;

>  HGLOBAL res = LoadResource(_Module.m_hInstResource,
> FindResource(_Module.m_hInstResource, MAKEINTRESOURCE(IDH_FORM),
RT_HTML));
>  if(!res)return -1;
>  m_wndView.Create(m_hWnd, rcClient, (LPCTSTR)LockResource(res),
>     WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);

> m_wndView.QueryControl(&m_htmlDoc);

> the last line returned E_FAIL. But the MSHTML control will be displayed
> without any problem(I can see the HTML in IDH_FORM)

> Another approach:

> m_htmlDoc.CreateInstance(CLSID_HTMLDocument);
> CComQIPtr<IPersistStreamInit> spPSI = m_htmlDoc;
> spPSI->InitNew();

> CComPtr<IAxWinHostWindow> spHost;
> m_wndView.QueryHost(IID_IAxWinHostWindow, (void**)&spHost);
> spHost->AttachControl(m_htmlDoc, m_wndView);

> m_htmlDoc->body->innerHTML = _bstr_t((LPCTSTR)LockResource(res));

> This approach also failed because QueryHost() returned E_FAIL and
> spHost.p was NULL.

> Please help me! Thanks.



Wed, 05 Nov 2003 18:03:57 GMT  
 CAxWindow::QueryHost and CAxWindow::QueryControl return E_FAIL
Hello Cramoisi,

CAxWindow::QueryControl returns pointer to interface of control. In your
case WebBrowser control is used.
To access DHTML DOM you should:
    1) IWebBrowser2 interface for hosted control, by QueryControl method.
    2) Call IWebBrowser2::get_Document

--
Best regards,
Vadim Melnik,
{*filter*} Consultant.
_____________________
http://www.*-*-*.com/


Quote:
> #import "mshtml.tlb"
> MSHTML::IHTMLDocument2Ptr m_htmlDoc;

>  HGLOBAL res = LoadResource(_Module.m_hInstResource,
> FindResource(_Module.m_hInstResource, MAKEINTRESOURCE(IDH_FORM),
RT_HTML));
>  if(!res)return -1;
>  m_wndView.Create(m_hWnd, rcClient, (LPCTSTR)LockResource(res),
>     WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);

> m_wndView.QueryControl(&m_htmlDoc);

> the last line returned E_FAIL. But the MSHTML control will be displayed
> without any problem(I can see the HTML in IDH_FORM)

> Another approach:

> m_htmlDoc.CreateInstance(CLSID_HTMLDocument);
> CComQIPtr<IPersistStreamInit> spPSI = m_htmlDoc;
> spPSI->InitNew();

> CComPtr<IAxWinHostWindow> spHost;
> m_wndView.QueryHost(IID_IAxWinHostWindow, (void**)&spHost);
> spHost->AttachControl(m_htmlDoc, m_wndView);

> m_htmlDoc->body->innerHTML = _bstr_t((LPCTSTR)LockResource(res));

> This approach also failed because QueryHost() returned E_FAIL and
> spHost.p was NULL.

> Please help me! Thanks.



Wed, 05 Nov 2003 19:06:21 GMT  
 CAxWindow::QueryHost and CAxWindow::QueryControl return E_FAIL
Should one never use MSHTML(CLSID_HTMLDocument) directly? Why?


Quote:
> Hello Cramoisi,

> CAxWindow::QueryControl returns pointer to interface of control. In your
> case WebBrowser control is used.
> To access DHTML DOM you should:
>     1) IWebBrowser2 interface for hosted control, by QueryControl method.
>     2) Call IWebBrowser2::get_Document

> --
> Best regards,
> Vadim Melnik,
> {*filter*} Consultant.
> _____________________
> http://www.*-*-*.com/



> > #import "mshtml.tlb"
> > MSHTML::IHTMLDocument2Ptr m_htmlDoc;

> >  HGLOBAL res = LoadResource(_Module.m_hInstResource,
> > FindResource(_Module.m_hInstResource, MAKEINTRESOURCE(IDH_FORM),
> RT_HTML));
> >  if(!res)return -1;
> >  m_wndView.Create(m_hWnd, rcClient, (LPCTSTR)LockResource(res),
> >     WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);

> > m_wndView.QueryControl(&m_htmlDoc);

> > the last line returned E_FAIL. But the MSHTML control will be displayed
> > without any problem(I can see the HTML in IDH_FORM)

> > Another approach:

> > m_htmlDoc.CreateInstance(CLSID_HTMLDocument);
> > CComQIPtr<IPersistStreamInit> spPSI = m_htmlDoc;
> > spPSI->InitNew();

> > CComPtr<IAxWinHostWindow> spHost;
> > m_wndView.QueryHost(IID_IAxWinHostWindow, (void**)&spHost);
> > spHost->AttachControl(m_htmlDoc, m_wndView);

> > m_htmlDoc->body->innerHTML = _bstr_t((LPCTSTR)LockResource(res));

> > This approach also failed because QueryHost() returned E_FAIL and
> > spHost.p was NULL.

> > Please help me! Thanks.



Wed, 05 Nov 2003 19:49:18 GMT  
 CAxWindow::QueryHost and CAxWindow::QueryControl return E_FAIL
Should one never use MSHTML(CLSID_HTMLDocument) directly? Why?


Quote:
> Hello Cramoisi,

> CAxWindow::QueryControl returns pointer to interface of control. In your
> case WebBrowser control is used.
> To access DHTML DOM you should:
>     1) IWebBrowser2 interface for hosted control, by QueryControl method.
>     2) Call IWebBrowser2::get_Document

> --
> Best regards,
> Vadim Melnik,
> {*filter*} Consultant.
> _____________________
> http://www.*-*-*.com/



> > #import "mshtml.tlb"
> > MSHTML::IHTMLDocument2Ptr m_htmlDoc;

> >  HGLOBAL res = LoadResource(_Module.m_hInstResource,
> > FindResource(_Module.m_hInstResource, MAKEINTRESOURCE(IDH_FORM),
> RT_HTML));
> >  if(!res)return -1;
> >  m_wndView.Create(m_hWnd, rcClient, (LPCTSTR)LockResource(res),
> >     WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);

> > m_wndView.QueryControl(&m_htmlDoc);

> > the last line returned E_FAIL. But the MSHTML control will be displayed
> > without any problem(I can see the HTML in IDH_FORM)

> > Another approach:

> > m_htmlDoc.CreateInstance(CLSID_HTMLDocument);
> > CComQIPtr<IPersistStreamInit> spPSI = m_htmlDoc;
> > spPSI->InitNew();

> > CComPtr<IAxWinHostWindow> spHost;
> > m_wndView.QueryHost(IID_IAxWinHostWindow, (void**)&spHost);
> > spHost->AttachControl(m_htmlDoc, m_wndView);

> > m_htmlDoc->body->innerHTML = _bstr_t((LPCTSTR)LockResource(res));

> > This approach also failed because QueryHost() returned E_FAIL and
> > spHost.p was NULL.

> > Please help me! Thanks.



Wed, 05 Nov 2003 19:49:02 GMT  
 CAxWindow::QueryHost and CAxWindow::QueryControl return E_FAIL
Should one never use MSHTML(CLSID_HTMLDocument) directly? Why?


Quote:
> Hello Cramoisi,

> CAxWindow::QueryControl returns pointer to interface of control. In your
> case WebBrowser control is used.
> To access DHTML DOM you should:
>     1) IWebBrowser2 interface for hosted control, by QueryControl method.
>     2) Call IWebBrowser2::get_Document

> --
> Best regards,
> Vadim Melnik,
> {*filter*} Consultant.
> _____________________
> http://www.*-*-*.com/



> > #import "mshtml.tlb"
> > MSHTML::IHTMLDocument2Ptr m_htmlDoc;

> >  HGLOBAL res = LoadResource(_Module.m_hInstResource,
> > FindResource(_Module.m_hInstResource, MAKEINTRESOURCE(IDH_FORM),
> RT_HTML));
> >  if(!res)return -1;
> >  m_wndView.Create(m_hWnd, rcClient, (LPCTSTR)LockResource(res),
> >     WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);

> > m_wndView.QueryControl(&m_htmlDoc);

> > the last line returned E_FAIL. But the MSHTML control will be displayed
> > without any problem(I can see the HTML in IDH_FORM)

> > Another approach:

> > m_htmlDoc.CreateInstance(CLSID_HTMLDocument);
> > CComQIPtr<IPersistStreamInit> spPSI = m_htmlDoc;
> > spPSI->InitNew();

> > CComPtr<IAxWinHostWindow> spHost;
> > m_wndView.QueryHost(IID_IAxWinHostWindow, (void**)&spHost);
> > spHost->AttachControl(m_htmlDoc, m_wndView);

> > m_htmlDoc->body->innerHTML = _bstr_t((LPCTSTR)LockResource(res));

> > This approach also failed because QueryHost() returned E_FAIL and
> > spHost.p was NULL.

> > Please help me! Thanks.



Wed, 05 Nov 2003 19:49:14 GMT  
 CAxWindow::QueryHost and CAxWindow::QueryControl return E_FAIL
I'm sorry that I misposted.

Now I have got both MSHTML and WebBrowser to work, thanks.

But I am wondering when do one need WebBrowser and when MSHTML will do.


Quote:
> Should one never use MSHTML(CLSID_HTMLDocument) directly? Why?



> > Hello Cramoisi,

> > CAxWindow::QueryControl returns pointer to interface of control. In your
> > case WebBrowser control is used.
> > To access DHTML DOM you should:
> >     1) IWebBrowser2 interface for hosted control, by QueryControl
method.
> >     2) Call IWebBrowser2::get_Document

> > --
> > Best regards,
> > Vadim Melnik,
> > {*filter*} Consultant.
> > _____________________
> > http://www.*-*-*.com/



> > > #import "mshtml.tlb"
> > > MSHTML::IHTMLDocument2Ptr m_htmlDoc;

> > >  HGLOBAL res = LoadResource(_Module.m_hInstResource,
> > > FindResource(_Module.m_hInstResource, MAKEINTRESOURCE(IDH_FORM),
> > RT_HTML));
> > >  if(!res)return -1;
> > >  m_wndView.Create(m_hWnd, rcClient, (LPCTSTR)LockResource(res),
> > >     WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);

> > > m_wndView.QueryControl(&m_htmlDoc);

> > > the last line returned E_FAIL. But the MSHTML control will be
displayed
> > > without any problem(I can see the HTML in IDH_FORM)

> > > Another approach:

> > > m_htmlDoc.CreateInstance(CLSID_HTMLDocument);
> > > CComQIPtr<IPersistStreamInit> spPSI = m_htmlDoc;
> > > spPSI->InitNew();

> > > CComPtr<IAxWinHostWindow> spHost;
> > > m_wndView.QueryHost(IID_IAxWinHostWindow, (void**)&spHost);
> > > spHost->AttachControl(m_htmlDoc, m_wndView);

> > > m_htmlDoc->body->innerHTML = _bstr_t((LPCTSTR)LockResource(res));

> > > This approach also failed because QueryHost() returned E_FAIL and
> > > spHost.p was NULL.

> > > Please help me! Thanks.



Wed, 05 Nov 2003 22:58:15 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Messaging for CAxWindow::CreateControl

2. _WIN32_WINNT and CAxWindow

3. CAxWindow::Create fails

4. WTL: CAxWindow Control Container Coms?

5. CAxWindow control in loops

6. Question about CAxWindow

7. Creating control in CAxWindow ?

8. CAxWindow problem with COINIT_MULTITHREADED

9. CAxWindow::AttachControl

10. How to use CAxWindow in ATL?

11. CAxWindow::DetachControl possible?

12. Tabs does not work in webbrowser control hosted by CAxWindow in CAxDialogImpl

 

 
Powered by phpBB® Forum Software