共用方式為


Application.RemoveMessageFilter(IMessageFilter) 方法

定義

從應用程式的訊息幫浦移除訊息篩選器。

public:
 static void RemoveMessageFilter(System::Windows::Forms::IMessageFilter ^ value);
public static void RemoveMessageFilter (System.Windows.Forms.IMessageFilter value);
static member RemoveMessageFilter : System.Windows.Forms.IMessageFilter -> unit
Public Shared Sub RemoveMessageFilter (value As IMessageFilter)

參數

value
IMessageFilter

要從應用程式中移除之 IMessageFilter 的實作。

範例

您必須先提供 介面的實作 IMessageFilter ,才能使用訊息篩選。 下列類別會建立名為 的 TestMessageFilter 訊息篩選。 此篩選會封鎖與滑鼠左鍵相關的所有訊息。

// Creates a  message filter.
ref class TestMessageFilter: public IMessageFilter
{
public:
   [SecurityPermission(SecurityAction::LinkDemand, Flags = SecurityPermissionFlag::UnmanagedCode)]
   virtual bool PreFilterMessage( Message % m )
   {
      
      // Blocks all the messages relating to the left mouse button.
      if ( m.Msg >= 513 && m.Msg <= 515 )
      {
         Console::WriteLine( "Processing the messages : {0}", m.Msg );
         return true;
      }

      return false;
   }

};
// Creates a  message filter.
public class TestMessageFilter : IMessageFilter
{
    public bool PreFilterMessage(ref Message m)
    {
        // Blocks all the messages relating to the left mouse button.
        if (m.Msg >= 513 && m.Msg <= 515)
        {
            Console.WriteLine("Processing the messages : " + m.Msg);
            return true;
        }
        return false;
    }
}
' Creates a message filter.
<SecurityPermission(SecurityAction.LinkDemand, Flags := SecurityPermissionFlag.UnmanagedCode)> _
Public Class TestMessageFilter
    Implements IMessageFilter

    <SecurityPermission(SecurityAction.Demand)> _
    Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) _
    As Boolean Implements IMessageFilter.PreFilterMessage
        ' Blocks all the messages relating to the left mouse button.
        If ((m.Msg >= 513) And (m.Msg <= 515)) Then
            Console.WriteLine("Processing the messages : " & m.Msg)
            Return True
        End If
        Return False
    End Function
End Class

備註

當您不想在分派 Windows 訊息之前擷取訊息時,可以移除訊息篩選。

適用於

另請參閱