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

Cannot reliably trap certain keys on the 10-key pad???

P: n/a
OC
Because of the requirements on a high-speed data entry form, I need to
reliably trap certain keys (specifically the "/", "*", "-", and "+") keys on
the 10-key pad and treat them as "Function keys". This MOSTLY works, however
I am finding that not with all workstations. Does anyone know what kind of
nuance might be involved here and how to avoid it? (I know it can be done
because the CICS emulators on these same workstations are able to remap
these keys via software.)

I am using the following in a base child form:

public bool PreFilterMessage(ref Message m)
{
const int WM_KEYDOWN = 0x100;
if (m.Msg == WM_KEYDOWN)
return HandleKeys((Keys)(int)m.WParam & Keys.KeyCode);
else
return false;
}

public BaseChildView()
{
InitializeComponent();
Application.AddMessageFilter(this);
mainMenu = new MainMenu();
}

private bool HandleKeys(Keys keyCode)
{
bool ret = false;
switch (keyCode)
{
case Keys.Enter: ret = EnterKeyPressed(); break;
case Keys.Add: ret = AddKeyPressed(); break;
case Keys.F1: ret = F1KeyPressed(); break;
case Keys.F2: ret = F2KeyPressed(); break;
case Keys.Divide: // used by ten-key data entry
case Keys.F3: ret = F3KeyPressed(); break;
case Keys.F4: ret = F4KeyPressed(); break;
case Keys.F5: ret = F5KeyPressed(); break;
case Keys.Multiply: // used by ten-key data entry
case Keys.F6: ret = F6KeyPressed(); break;
case Keys.F7: ret = F7KeyPressed(); break;
case Keys.F8: ret = F8KeyPressed(); break;
case Keys.Subtract: // used by ten-key data entry
case Keys.F9: ret = F9KeyPressed(); break;
case Keys.F10: ret = F10KeyPressed(); break;
case Keys.F11: ret = F11KeyPressed(); break;
case Keys.F12: ret = F12KeyPressed(); break;
default: ret = false; break;
}
return ret;
}

protected virtual bool EnterKeyPressed() {return false;}
protected virtual bool AddKeyPressed() {return false;}
protected virtual bool F1KeyPressed() {return false;}
protected virtual bool F2KeyPressed() {return false;}
protected virtual bool F3KeyPressed() {return false;}
protected virtual bool F4KeyPressed() {return false;}
protected virtual bool F5KeyPressed() {return false;}
protected virtual bool F6KeyPressed() {return false;}
protected virtual bool F7KeyPressed() {return false;}
protected virtual bool F8KeyPressed() {return false;}
protected virtual bool F9KeyPressed() {return false;}
protected virtual bool F10KeyPressed() {return false;}
protected virtual bool F11KeyPressed() {return false;}
protected virtual bool F12KeyPressed() {return false;}

private void BaseChildView_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
Application.RemoveMessageFilter(this);
}
Nov 15 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.