C # Methods for intercepting system messages Application.addmessagefilter Application.addmessagefilter This method can receive messages from the system: first define a class, Inherit the IMessageFilter interface code as follows:
Internal class Mymessager:imessagefilter
{
Intercept messages and process them
public bool Prefiltermessage (ref System.Windows.Forms.Message m)
{
Switch (m.msg)
{
Case 513://Intercept left-click event
MessageBox.Show ("left button is blocked! ");
return true;
Case 516://Intercept left-click event
MessageBox.Show ("Right button is intercepted!") ");
return true;
Default
return false; Returns False when the message is not cropped and the system processes
}
}
}
Then add the Application.addmessagefilter method to the form Load event
private void Form1_Load (object sender, EventArgs e)
{
Application.addmessagefilter (New Mymessager ());
}
C # Methods for intercepting system messages-application.addmessagefilter