BEGIN_SINK_MAP(CMainDlg) SINK_ENTRY(IDC_EXPLORER1, ..。响应不到的
</pre><pre name="code" class="cpp">
class CMainDlg : public CAxDialogImpl<CMainDlg>, public CUpdateUI<CMainDlg>, public CMessageFilter, public CIdleHandler, public IDispEventImpl<IDC_EXPLORER1, CMainDlg> { public: enum { IDD = IDD_MAINDLG }; virtual BOOL PreTranslateMessage(MSG* pMsg) { return CWindow::IsDialogMessage(pMsg); } virtual BOOL OnIdle() { UIUpdateChildWindows(); return FALSE; } BEGIN_UPDATE_UI_MAP(CMainDlg) END_UPDATE_UI_MAP() BEGIN_MSG_MAP(CMainDlg) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) END_MSG_MAP() BEGIN_SINK_MAP(CMainDlg) SINK_ENTRY(IDC_EXPLORER1, DISPID_NEWWINDOW3, OnNewBrowser) END_SINK_MAP() void __stdcall OnNewBrowser( IDispatch **ppDisp, VARIANT_BOOL *Cancel, DWORD dwFlags, BSTR bstrUrlContext, BSTR bstrUrl); };
我去,这代码,OnNewBrowser这东西死活不响应,找来找去最后发现
LRESULT CMainDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { // center the dialog on the screen CenterWindow(); // set icons HICON hIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON)); SetIcon(hIcon, TRUE); HICON hIconSmall = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON)); SetIcon(hIconSmall, FALSE); // DoDataExchange(false); // register object for message filtering and idle updates CMessageLoop* pLoop = _Module.GetMessageLoop(); ATLASSERT(pLoop != NULL); pLoop->AddMessageFilter(this); pLoop->AddIdleHandler(this); ModifyStyleEx(WS_EX_APPWINDOW, WS_EX_TOOLWINDOW, 0); UIAddChildWindowContainer(m_hWnd); // Attach ID to web browser control. m_browserWnd = GetDlgItem(IDC_EXPLORER1); ATLASSERT( NULL != m_browserWnd ); m_browserWnd.QueryControl(&m_spWebBrowser); ATLASSERT( NULL != m_spWebBrowser ); AtlAdviseSinkMap(this, true); //尼玛,就是加上你就行了</span> }
Call this function to advise or unadvise all entries in the object's sink event map.
HRESULT AtlAdviseSinkMap( T* pT, bool bAdvise ); |