Live Chat Icon For mobile
Live Chat Icon

How do I listen to windows messages in my Control?

Platform: WinForms| Category: Controls

In a derived class you should override WndProc as follows (listening to the WM_KEYUP message, for example):

public class MyCombo : ComboBox
         private const int WM_KEYUP = 0x101;

         protected override void WndProc(ref System.Windows.Forms.Message m)
                  if(m.Msg == WM_KEYUP)
                           return;  //ignore the keyup
                  base.WndProc(ref m);

Public Class MyTextBox
	Inherits TextBox
	Private WM_KEYUP As Integer = &H101
	Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
		If m.Msg = WM_KEYUP Then
			Return ’ignore the keyup
		End If
	End Sub ’WndProc
End Class ’MyTextBox

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.