Example #1
0
 /// <summary>
 /// Window Procedure: Processes all Window messages looking for a registered 
 /// message and calls the associated msg handler (delegate).
 /// </summary>
 /// <param name="m"></param>		
 protected override void WndProc(ref Message m)
 {
     MsgTrap msgTrap = new MsgTrap(m.Msg, null);
     int num = this.msgTrapList.BinarySearch(0, this.msgTrapList.Count, msgTrap, MsgTrap.sortMsg());
     if (num < 0)
     {
         base.WndProc(ref m);
         return;
     }
     msgTrap = (MsgTrap)this.msgTrapList[num];
     msgTrap.InvokeHandler(ref m);
 }
Example #2
0
 /// <summary>
 /// Registers a new Message to the trapped and its associated handler (delegate)
 /// </summary>
 /// <param name="msg">Windows message number to trap</param>
 /// <param name="WM_Handler">Handler to invoke. Null=Unregister</param>
 public bool AddHandler(int msg, WM_Delegate WM_Handler)
 {
     MsgTrap msgTrap = new MsgTrap(msg, WM_Handler);
     if (this.msgTrapList.Contains(msgTrap))
     {
         return false;
     }
     if (WM_Handler != null)
     {
         this.msgTrapList.Add(msgTrap);
     }
     else
     {
         this.msgTrapList.Remove(msgTrap);
     }
     return true;
 }