Vs2010 Atl工程手工添加连接点

背景:

  新建Atl工程:atlTT

  添加ATL Simple ObjectSimpleEvent,不选择支持连接点

 

修改atlTT.idl,摘录如下,红色为手工添加的部分

library atlTTLib

{

    importlib("stdole2.tlb");

 

    [

        uuid(F6223641-CD95-44CF-B121-9DA1CC416522)        

    ]

    dispinterface _ISimpleEventEvents

    {

        properties:

        methods:

            [id(1)] HRESULT OnAdd(LONG lValue);    

};

 

    [

        uuid(B7560BBD-7D1D-4082-8AD4-A5DD35633E1C)        

    ]

    coclass SimpleEvent

    {

        [default] interface ISimpleEvent;

        [default, source] dispinterface _ISimpleEventEvents;

    };

};

 

先编译工程,再在Class View中通过右键菜单"Add Connection Point…",添加连接点实现,如下图。

注意点:1、选择菜单"Add Connection Point…",而非"Implement Interface…"

              2、对话框中,Availabel type library列表选择"atlTTlib<1.0>",而非"Embedded IDL"

点击按钮"Finish",然后在Solution Explorer中就能看到新生成的文件"_ISimpleEventEvents_CP.h",文件中有"HRESULT Fire_OnAdd(LONG lValue)"的实现,触发事件只要调用Fire_OnAdd。



深入解析连接点(还未细看,介绍了使用连接点来进行进程间通信

http://blog.csdn.net/debehe/article/details/2291771

原文地址:https://www.cnblogs.com/ant-wjf/p/3251187.html