Custom control's KeyDown / KeyPress event not fired?

T

tamberg

Is it possible that a trivial (class MyControl: Control {}) custom
control's KeyDown / KeyPress events are not fired on .NET CF 1.1 for
PPC2003 / WM5? This seems strange as the events are fired on SP2003.
 
P

Paul G. Tobey [eMVP]

There's no such thing as .NET CF 1.1.

I think you'll have to show us the simplest code that demonstrates the
problem.

Paul T.
 
T

tamberg

Sorry, I meant .NET CF 1.0. Here's an example:

using System;
using System.Drawing;
using System.Windows.Forms;

class MyControl: Control {}

class KeyTest {

static Label log;

static void Log (string msg) { log.Text += msg; }
static void KeyDown (object o, KeyEventArgs a) { Log("Down "); }
static void KeyPress (object o, KeyPressEventArgs a) { Log("Press
"); }
static void KeyUp (object o, KeyEventArgs a) { Log("Up\n"); }

static void Main () {
Form f = new Form();
f.Text = "KeyTest";
MyControl mc = new MyControl();
mc.Bounds = new Rectangle(0, 0, f.ClientSize.Width, 7);
mc.KeyDown += new KeyEventHandler(KeyDown);
mc.KeyPress += new KeyPressEventHandler(KeyPress);
mc.KeyUp += new KeyEventHandler(KeyUp);
f.Controls.Add(mc);
log = new Label();
log.Bounds = new Rectangle(0, mc.Height, f.ClientSize.Width,
f.ClientSize.Height - mc.Height);
f.Controls.Add(log);
Application.Run(f);
}

}

..NET CF 1.0 compiling and running it on a PC / PPC2003 / WM5 leads to
this:

one of the arrow keys => "Up"
alphabetical key => "Down Press Up"
alphabetical key hold => "Down Press Down Press ... Down Press Up"

while running it on a Smartphone 2003 leads to:

one of the arrow keys => "Down Up"

Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top