• 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>
    }


    MSDN解释

    Call this function to advise or unadvise all entries in the object's sink event map.

     
    HRESULT AtlAdviseSinkMap(
       T* pT,
       bool bAdvise 
    );




  • 相关阅读:
    C#总结(四)调用C++动态库
    Golang 入门系列(十二)ORM框架gorm
    《关键对话》如何高效沟通,营造无往不利的事业和人生?
    Golang 入门系列(十一)Go语言实现webapi
    Golang 入门系列(十) mysql数据库的使用
    Golang 入门系列(九) 如何读取YAML,JSON,INI等配置文件
    Golang 入门系列(八) cron定时任务
    Golang 入门系列(七) Redis的使用
    福利 | 互联网产品经理学习资料免费下载(可下载)
    福利 | 2018各大技术大会资料汇总(可下载)
  • 原文地址:https://www.cnblogs.com/yuzhould/p/4454248.html
Copyright © 2020-2023  润新知