类模块之四:MsgSrv.cls----本模块中定义了消息服务器类MsgServer,该类是消息广播引擎的主体,它主要管理维护消息接收器列表(Clients),将发送来的消息(调用SendMsg过程)依次发送给列表中的所有接收器。注意,这个类被声明为公共全局类,这主要是为了方便使用(不必在每个程序中再建立该类,过程名全局有效)。
VERSION 1.0 CLASS BEGIN MultiUse = -1 'True END Attribute VB_Name = "MsgServer" Attribute VB_GlobalNameSpace = True Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = True Option Explicit ' 说 明: ' 消 息 服 务 器 类 '------------------------------- ' 发 送 消 息 Public Sub SendMsg(msg As VbMsg) Dim c As MsgClient For Each c In Clients c.SetMsg msg DoEvents Next c End Sub ' 增 删 消 息 接 收 客 户 Public Sub AddMsgClient(c As MsgClient) CliCount = CliCount + 1 c.Id = CliCount Clients.Add c, c.Key End Sub Public Sub DelMsgClient(c As MsgClient) Clients.Remove c.Key If Clients.Count = 0 Then CliCount = 0 End Sub |
正在阅读:在VB程序中处理随机事件在VB程序中处理随机事件
2005-06-10 10:20
出处:
责任编辑:moningfeng
键盘也能翻页,试试“← →”键