M
mdb
I'm trying to restrict the characters that are valid in a textBox, so I
derived from System.Windows.Forms.TextBox, and overrode WndProc, catching
the key up/down messages... Everything works except the arrow keys - the
text cursor never moves. Why won't the arrows work? I know I'm catching
the correct WParam values...
protected override void WndProc(ref Message m)
{
if ((m.Msg == 256) || (m.Msg == 258))
{
int v = (int)m.WParam;
if ((v > (int)'0') && (v < (int)'9'))
{
base.WndProc (ref m);
return;
}
switch(v)
{
case 8: // Backspace
case 13: // Enter
case 33: // PgUp
case 34: // PgDn
case 35: // End
case 36: // Home
case 37: // Left
case 38: // Up
case 39: // Right
case 40: // Down
case 46: // Delete
base.WndProc(ref m);
break;
default:
break;
}
}
else
{
base.WndProc(ref m);
}
}
derived from System.Windows.Forms.TextBox, and overrode WndProc, catching
the key up/down messages... Everything works except the arrow keys - the
text cursor never moves. Why won't the arrows work? I know I'm catching
the correct WParam values...
protected override void WndProc(ref Message m)
{
if ((m.Msg == 256) || (m.Msg == 258))
{
int v = (int)m.WParam;
if ((v > (int)'0') && (v < (int)'9'))
{
base.WndProc (ref m);
return;
}
switch(v)
{
case 8: // Backspace
case 13: // Enter
case 33: // PgUp
case 34: // PgDn
case 35: // End
case 36: // Home
case 37: // Left
case 38: // Up
case 39: // Right
case 40: // Down
case 46: // Delete
base.WndProc(ref m);
break;
default:
break;
}
}
else
{
base.WndProc(ref m);
}
}