网站公告列表

  没有公告

加入收藏
设为首页
在线投稿

您现在的位置: IT知识网 >> IT知识 >> 维修维护 >> 其它外设维护维修 >> 文章正文

 

  Mdi子窗口间消息通信           

Mdi子窗口间消息通信
作者:佚名 文章来源:不详 点击数: 更新时间:2006-12-6 1:09:27
    Mdi子窗口间消息通信
    Mdi子窗口间消息通信    
      using System;;
    
    namespace Vavic
    {
    /// 〈summary〉
    /// 当信息更改是通知其他的窗口重新加载数据
    /// 使用方法为:1)通知信息更改
    /// Notify.Instance().SendMessage(100, "Form1 Activate test notify event");;
    /// 其中第一个参数为信息号,第二个参数为信息描述
    /// 2)收取信息
    /// 使用方法,在每个FORMLOAD事件中加入如下语句
    /// Notify.Instance().OnNotifyEvent += new Notify.NotifyEvent(OnNotifyEvent);;
    /// 同时编写如下的方法用于重新加载数据
    ///protected void OnNotifyEvent(object sender, Notify.NotifyEventArgs e)
    ///{
    /// if (e.Code == Notify.CompanyInfo)
    /// System.Diagnostics.Debug.WriteLine(string.Format(" Form1 Code={0}, Message = {1}", e.Code,e.Message));;
    ///}
    /// 〈/summary〉
    public class Notify
    {
    
      protected static Notify m_notify = null;;
    
      public delegate void NotifyEvent(object sender, NotifyEventArgs e);;
    
      public event NotifyEvent OnNotifyEvent;;
    
      protected Notify()
    
      {
    
       //
    
       // TODO: 在此处添加构造函数逻辑
    
       //
    
      }
    
    
      public static Notify Instance()
    
      {
    
       if (m_notify == null)
    
       m_notify = new Notify();;
    
       return m_notify;;
    
      }
    
      
    
      public void SendMessage(int code, string message)
    
      {
    
       NotifyEventArgs e = new NotifyEventArgs(code, message);;
    
       if ( OnNotifyEvent != null)
    
       OnNotifyEvent(this, e);;
    
      }
    
    
    
      public class NotifyEventArgs : System.EventArgs
    
      {
    
       public NotifyEventArgs(int code, string message)
    
       {
    
       m_nCode = code;;
    
       m_strMessage = message;;
    
       }
    
    
       public NotifyEventArgs()
    
       {
    
       }
    
    
       protected int m_nCode;;
    
       public int Code
    
       {
    
       get { return m_nCode;;}
    
       set { m_nCode = value;;}
    
       }
    
    
       protected string m_strMessage = string.Empty;;
    
       public string Message
    
       {
    
       get { return m_strMessage;;}
    
       set
    
       {
    
       m_strMessage = value;;
    
       if (m_strMessage == null)
    
       m_strMessage = string.Empty;;
    
       }
    
       }
    
      }
    
    
      #region Common Infomation
    
      public const int CompanyInfo = 1;;
    
      public const int ProjectInfo = 2;;
    
      public const int TaskInfo = 3;;
    
      public const int Opportunity = 4;;
    
      public const int Contactor = 5;;
    
      public const int EmployeeInfo = 6;;
    
      public const int DepartmentInfo = 7;;
    
      public const int AdvCityInfo = 8;;
    
      #endregion
    }
    }
    
  

文章录入:wuyongjian    责任编辑:wuyongjian 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最 新 热 门
    相 关 文 章
    use a route-map to lim
    Cisco MDS 9000 系列交换
    在Catalyst交换机配置TA
    两个IP QoS标准:DiffSe
    Cisco MDS9000交换机高性
    Cisco MDS 9216多层光纤
    Cisco MDS9000交换机高性
    Configuring Dial-on-De
    打造属于自己的路由器 路
    轻松DIY路由器 解决双网
     
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    Copyright© ITZS.NET All Rights Reserved
    QQ:272895858   ICP备案编号:吉ICP备07000044号
    IT知识网 站长:博浪