我使用如下的方法:
BEGIN_DHTML_EVENT_MAP(CMyView)
DHTML_EVENT(0x000003ff,NULL,oncontextmenu)
END_DHTML_EVENT_MAP()
我想把 document 对象的oncontextmenu事件映射到我的oncontextmenu
msdn 中说
DHTML_EVENT(dispid, elemName, memberFxn )elemName 
An LPCWSTR holding the ID of the HTML element sourcing the event, or NULL to handle document events. 
也就是说ID ==NULL 默认映射Document 对象的事件,实际使用的的时候,发现映射根本就没有成功,不知道为什么?如何映射documnet的事件那

解决方案 »

  1.   

    当你继承Document映射时,可以使用NULL,但当你在你的View内映射事件时,必须使用该HtmlDocument在你的View内的ID
      

  2.   

    HtmlDocument在你的View内的ID
    如何知道哪
      

  3.   

    我不知道你是用什么方法实现的,一般使用HtmlDocument都是创建一个控件,通过该控件的IUnknown接口可以查询出IHtmlDocument接口并访问 CLSID const& GetClsid()
    {
    static CLSID const clsid
    = { 0x8856f961, 0x340a, 0x11d0, { 0xa9, 0x6b, 0x0, 0xc0, 0x4f, 0xd7, 0x5, 0xa2 } };
    return clsid;
    }
    virtual BOOL Create(LPCTSTR lpszClassName,
    LPCTSTR lpszWindowName, DWORD dwStyle,
    const RECT& rect,
    CWnd* pParentWnd, UINT nID,
    CCreateContext* pContext = NULL)
    { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID); }该控件创建时应该指定一个ID值,该值不与同一对话框或者同一窗口内的其他控件ID重复就可以了
      

  4.   

    document的事件ID和element的不一样,需要注意
      

  5.   

    document的事件ID和element的不一样,需要注意
    能不能给个详细的说明
      

  6.   

    HTMLDocumentEvents2 DispinterfaceThis dispinterface provides a connection point so that an application or control can intercept events fired by a document object.HTMLElementEvents2 Dispinterface
    This dispinterface provides a connection point so that an application or control can intercept events fired by an element.Header and IDL files mshtml.h, mshtml.idl 
      

  7.   

    建议你贴你document创建的相关代码
      

  8.   


    建议你贴你document创建的相关代码
      

  9.   

    看看这个例子有用不
    http://www.vchelp.net/wyy/paper/z_html_dlg.asp