Re: containing an IE browser control
Joe Andrieu <joe-SkMv+1uwgv/[email protected]>
| Newsgroups | gmane.comp.windows.wtl |
|---|---|
| Message-ID | <[email protected]> |
One thing you might try is adding the traits in the inheritance declaration:
public CWindowImpl<Browser,CAxWindow,CWinTraits<WS_CHILD |
WS_CLIPCHILDREN | WS_CLIPSIBLINGS> >
Btw, I know these are slightly different traits than you have, but they
worked for me the last time I used the webbrowser control.
The only other thing I can think of is that I didn't use the
DECLARE_WND_SUPERCLASS macro. Try commenting that out.
-j
Joe Andrieu
joe-SkMv+1uwgv/[email protected]
+1 (805) 705-8651
On 7/31/2010 7:02 AM, addicted2freefall wrote:
> I've written a quick class to contain an IE browser control
>
> class Browser : public CWindowImpl<Browser, CAxWindow>
> {
> public:
> DECLARE_WND_SUPERCLASS(_T("BrowserCntr"), CAxWindow::GetWndClassName());
>
> BOOL PreTranslateMessage( MSG* pMsg )
> {
> pMsg;
> return FALSE;
> }
>
> HWND Create(
> HWND hwndOwner,
> RECT& rcPos,
> DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
> DWORD dwExStyle = WS_EX_CLIENTEDGE,
> UINT nID = 0,
> LPVOID lpCreateParam = NULL
> )
> {
>
> HWND hWnd = CWindowImpl<Browser, CAxWindow>::Create(
> hwndOwner,
> rcPos,
> _T("{8856F961-340A-11D0-A96B-00C04FD705A2}"),
> dwStyle,
> dwExStyle
> );
>
> return hWnd;
> }
>
> BEGIN_MSG_MAP( Browser )
> END_MSG_MAP()
>
> };
>
>
> When I attempt to add an instance of the Browser to my CMainFrame, the browser control sits on the desktop:
>
> LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
> {
> CComQIPtr<IWebBrowser2> m_spBrowser;
> CComVariant v;
>
> RECT rect;
>
> GetClientRect(&rect);
>
> m_hWndClient = m_browser.Create( m_hWnd, rect );
> m_browser.QueryControl(&m_spBrowser );
>
> if( m_spBrowser )
> m_spBrowser->Navigate( CComBSTR("http://www.google.com"),&v,&v,&v,&v);
>
> // register object for message filtering and idle updates
> CMessageLoop* pLoop = _Module.GetMessageLoop();
> ATLASSERT(pLoop != NULL);
> pLoop->AddMessageFilter(this);
> pLoop->AddIdleHandler(this);
>
> return 0;
> }
>
> How can I ensure that it's a child window of the CMainFrame - e.g. the m_hWndClient window?
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/wtl/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/wtl/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/