我写了一个测试网页
<BODY>
<OBJECT ID="test2" CLASSID="CLSID:D1413D1E-0868-4158-A556-9463E13F4B13"></OBJECT>
<OBJECT ID="test" CLASSID="CLSID:723531DF-C92C-44CB-BC14-49B9C917A594"></OBJECT>
<script>
test2.attachEvent("OnTest", Ontest2);
test.attachEvent("OnTest", Ontest);
test.test();
test2.test();
function Ontest2()
{
alert("test2");
}
function Ontest()
{
alert("test");
}
</script>
</BODY>
其中test2是用ATL建立的一个full control,Apartment模型,dual接口,支持连接点.
test是用ATL建立的一个simple object,Apartment模型,dual接口,支持连接点.
这两个对象都增加了事件OnTest,并且都在test方法中调用了Fire_OnTest();
但是网页运行的结果是只弹出对话框"test2".请问要怎样才能在用simple object的情况下使用事件
<BODY>
<OBJECT ID="test2" CLASSID="CLSID:D1413D1E-0868-4158-A556-9463E13F4B13"></OBJECT>
<OBJECT ID="test" CLASSID="CLSID:723531DF-C92C-44CB-BC14-49B9C917A594"></OBJECT>
<script>
test2.attachEvent("OnTest", Ontest2);
test.attachEvent("OnTest", Ontest);
test.test();
test2.test();
function Ontest2()
{
alert("test2");
}
function Ontest()
{
alert("test");
}
</script>
</BODY>
其中test2是用ATL建立的一个full control,Apartment模型,dual接口,支持连接点.
test是用ATL建立的一个simple object,Apartment模型,dual接口,支持连接点.
这两个对象都增加了事件OnTest,并且都在test方法中调用了Fire_OnTest();
但是网页运行的结果是只弹出对话框"test2".请问要怎样才能在用simple object的情况下使用事件
IProvideClassInfo interfaces. This is done by deriving your control from the
default ATL implementation, IProvideClassInfo2Impl.
1. Add the following line to your class derivation list:
public IProvideClassInfo2Impl<&CLSID_<object_name>, NULL,
&LIBID_<project_name>Lib>
2. Add the following lines to your COM_MAP:
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
Hope that helps. For additional information you can take a look at KB Q200839