By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,089 Members | 1,952 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,089 IT Pros & Developers. It's quick & easy.

Supress KeyDown event in custom class

P: n/a
I have a custom control that contains a class that Inherits the panel
control. I am trying to catch a keydown event in this class and then
supress it from the rest of the control as well as the form that hosts
the control. The problem I am running into is that the form that hosts
the control will respond to the keydown event event.

Any ideas what I am missing?

Some source code to help:

public class PanelEditor : Panel {

... boring code omitted....

protected override void OnKeyDown(KeyEventArgs e) {
this.m_Text += (Keys)e.KeyValue;
this.m_CharCount++;

e.Handled =true;
base.OnKeyDown (e);
}
}

Again, this derived panel is part of a C# Windows Control Library.

-David
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ok, I have it fixed. Here is the code that would replace the OnKeyDown override and supress the key

public override bool PreProcessMessage(ref Message msg)
switch(msg.Msg)
case 0x0100: //WM_KEYDOW

... Do your key stuff here ..

msg.WParam = IntPtr.Zero; //Set this to zero to supress the key strok
break
return base.PreProcessMessage (ref msg)
}
Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.