Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Understanding the basics, implementing a IDocHostUIHandler in ATL

68 views
Skip to first unread message

sam

unread,
Nov 21, 2010, 6:17:46 PM11/21/10
to
Ok, I have a ATL app that is a wrapper around the WebBrowser control,
what is the correct way to implement a custom IDocHostUIHandler?
Below is what the basic setup. There is a CWindowImpl (CKioskWindow)
which contains the CAxWindow to host the WebControl.

The questions I have are:

1: Who should implement IDocHostUIHandler? CKioskWindow, should I
derive from CAxWindow and have it implement the interface, or should
it be its own class?
2: How and when should it be wired in so that it can be used?

Code snippet:

class CKioskWindow
: public CWindowImpl<CKioskWindow, CWindow, CKioskTraits>
, public IDispEventImpl<ID_WEBBROWSER, CKioskWindow>
{
public:
LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
RECT rect;
GetClientRect(&rect);

HWND hwndContainer = m_axBrowser.Create(m_hWnd, rect, 0, WS_CHILD|
WS_VISIBLE, 0, ID_WEBBROWSER);
if( !hwndContainer) {
return -1;
}

CComPtr<IAxWinHostWindow> spAxWindow;
if(SUCCEEDED(hr)) {
hr = m_axBrowser.QueryHost(&spAxWindow);
}

// Create the control in the Host window
if( SUCCEEDED(hr)) {
LPOLESTR pszName = OLESTR("Shell.Explorer");
//LPOLESTR pszName = OLESTR("Mozilla.Browser");
hr = spAxWindow->CreateControl(pszName, m_axBrowser.m_hWnd, NULL);
}

}

private:
CAxWindow m_axBrowser;
}

0 new messages