This documentation is archived and is not being maintained.

IMessageFilter.PreFilterMessage Method

Filters out a message before it is dispatched.

[Visual Basic]
Function PreFilterMessage( _
   ByRef m As Message _
) As Boolean
bool PreFilterMessage(
   ref Message m
bool PreFilterMessage(
   Message* m
function PreFilterMessage(
   m : Message
) : Boolean;


The message to be dispatched. You cannot modify this message.

Return Value

true to filter the message and stop it from being dispatched; false to allow the message to continue to the next filter or control.


Use PreFilterMessage to filter out a message before it is dispatched to a control or form. For example, to stop the Click event of a Button control from being dispatched to the control, you implement the PreFilterMessage method and return a true value when the Click message occurs. You can also use this method to perform code work that you might need to do before the message is dispatched.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

IMessageFilter Interface | IMessageFilter Members | System.Windows.Forms Namespace