Override the control's WndProc method. This sample shows a custom control that is a ComboBox that discards the WM_KEYUP message.
[C#]
using System.Windows.Forms;
public class ComboBoxWithNoKeyUp : ComboBox
{
private const int WM_KEYUP = 0x101;
protected override void WndProc(ref Message m)
{
if ( m.Msg == WM_KEYUP )
return;
base.WndProc (ref m);
}
}
[Visual Basic]
Imports System.Windows.Forms
Public Class ComboBoxWithNoKeyUp
Inherits ComboBox
Private Const WM_KEYUP As Integer = &H101
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_KEYUP Then
Return
End If
MyBase.WndProc(m)
End Sub
End Class
Contributed from George Shepherd's Windows Forms FAQ