Application.RemoveMessageFilter : Application « System.Windows.Forms « C# / C Sharp by API






Application.RemoveMessageFilter

 


using System;
using System.Windows.Forms;

public class mainForm : System.Windows.Forms.Form
{
  private MyMessageFilter msgFliter = new MyMessageFilter();

  public mainForm()
  {
    Application.ApplicationExit += new EventHandler(Form_OnExit);

    Application.AddMessageFilter(msgFliter);    
  }

  [STAThread]
  static void Main() 
  {
    Application.Run(new mainForm());
  }
  private void Form_OnExit(object sender, EventArgs evArgs) 
  {
    Application.RemoveMessageFilter(msgFliter);
  }
}

public class MyMessageFilter : IMessageFilter 
{
  public bool PreFilterMessage(ref Message m) 
  {
    // Intercept the left mouse button down message.
    if (m.Msg == 513) 
    {
      Console.WriteLine("WM_LBUTTONDOWN is: " + m.Msg);
      return true;
    }
    return false;
  }
}

   
  








Related examples in the same category

1.Application.AddMessageFilter
2.Application.ApplicationExit
3.Application.CompanyName
4.Application.Idle
5.Application.ProductName
6.Application.Run
7.Application.StartupPath
8.Application.ThreadException
9.Application.ThreadExit