Re: Adding dynamically DHTML_EVENT to DHTML_EVENT_MAP
<pistonep@hotmail.com> wrote in message
news:1177079289.819227.265720@p77g2000hsh.googlegroups.com...
Thanks to you David.
Well to resume I have an HTML :
<script>
function addRow(id)
{
//add a row to the main table with the id provided
}
<script>
<body>
<table>
</table>
</body>
I have my C++ CDHTMLDialog attached to this html file, so when i start
the program i have a blank page.
My main c++ program has a fucntion call
void AddHTMLRow(CString sString)
{
//call addRow function of the jcript passing a id got in the CString
}
and now I could not catch event if this specific row because I have
not set DHTML_EVENT_ONCLICK with the right (unknown at te begining) id
Oh, OK. What I do is use the DHTML_EVENT_TAG to add map entries so my
handler is called when that event occurs on the specified tag. For example:
DHTML_EVENT_TAG(DISPID_HTMLELEMENTEVENTS_ONCLICK, _T("a"),
OnHtmlLinkClicked)
Also, I use the following code to intercept events from all possible tags.
It defines a DHTML_EVENT_TAG_ALL macro:
// From "Dialog with HTML skin using CDHtmlDialog and SetWindowRgn"
// http://www.codeproject.com/dotnet/HtmlSkinCDHtmlDialog.asp
// Define the macro for mapping one event from all HTML tags
#define DHTML_EVENT_TAG_ALL(dispid, memberFxn) { DHTMLEVENTMAPENTRY_TAG, dispid, _T("a"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("abbr"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("acronym"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("address"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("applet"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("area"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("b"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("base"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("basefont"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("bdo"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("big"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("blockquote"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("body"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("br"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("button"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("caption"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("center"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("cite"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("code"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("col"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("colgroup"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("dd"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("del"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("dir"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("div"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("dfn"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("dl"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("dt"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("em"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("fieldset"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("font"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("form"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("frame"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("frameset"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("h1"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("h2"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("h3"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("h4"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("head"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("hr"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("html"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("i"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("iframe"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("img"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("input"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("ins"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("isindex"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("kbd"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("label"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("legend"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("li"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("link"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("map"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("menu"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("meta"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("noframes"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("noscript"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("object"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("ol"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("optgroup"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("option"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("param"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("pre"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("q"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("s"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("samp"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("script"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("select"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("small"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("span"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("strike"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("strong"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("style"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("sub"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("sup"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("table"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("tbody"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("td"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("textarea"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("tfoot"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("th"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("thead"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("title"), (DHEVTFUNCCONTROL)
(DHEVTFUNC) theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("tr"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("tt"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("u"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("ul"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("var"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn }, { DHTMLEVENTMAPENTRY_TAG, dispid, _T("xmp"), (DHEVTFUNCCONTROL) (DHEVTFUNC)
theClass::memberFxn },
and then in my map I put:
BEGIN_DHTML_EVENT_MAP(CDHtmlPopupYesDlg)
DHTML_EVENT_TAG_ALL(DISPID_HTMLELEMENTEVENTS_ONMOUSEDOWN, OnHtmlMouseDown)
END_DHTML_EVENT_MAP()
Hope this helps,
David