连接点

一个COM组件允许有许多个连接点对象(IConnectionPoint),管理这些接点对象的接口叫做连接点容器(IconnectionPointContainer), 连接点容器接口比较简单,只有两个函数,一个是FindConnectionPoint(),表示你想查找的连接点,另一个是EnumConnectionPoint(),表示列出所有的连接点,然后你去选择使用哪个连接点,每一个连接点可以被多个客户端的接收器(Sink)连接。

Instance below:

1, New a project named Connection based ATL, select "New ATL Object" in pop menu that right click the project in ClassView. Input the name and chose the "support connection points" in tab "Attributes", now, the project model has been finished.

2, Add method for the interface , then add envent for dealing with the operation, only compile the idl file or compile the project(no need for more spend), the interface enter implement connection points and check the choice in dialog "Implement Connection Points", the frame will generate some code for connect to the event.

3,New a test project for check the correct of the COM, first import the head file and .tlb, new a class based general derived from IDispatch, then you should implement the virtual function defined in IUnknown(QueryInterface, AddRef, Release) and IDispatch(GetTypeInfo, GetTypeInfoCount, GetIDsOfName, Invoke),the important function is Invoke, it will recieve the message customer advise, according the parameter dispID you can invoke different method. 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值