I don't know what kind of output you expect, but i have made a little example. The ToUnicode method, is that a custom method
private void control_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { switch(e.KeyCode) { case Keys.NumPad0: case Keys.NumPad1: case Keys.NumPad2: case Keys.NumPad3: case Keys.NumPad4: case Keys.NumPad5: case Keys.NumPad6: case Keys.NumPad7: case Keys.NumPad8: case Keys.NumPad9: { char append = (char)(e.KeyCode - Keys.NumPad0); ascii_key = string.Format( "0{0}", append ); } } }
KeyboardHandlers::OnKeyDown(HBaseViewClr^ hView, UINT nChar, bool bAlt) { switch (nChar) { case VK_NUMPAD0: case VK_NUMPAD1: case VK_NUMPAD2: case VK_NUMPAD3: case VK_NUMPAD4: case VK_NUMPAD5: case VK_NUMPAD6: case VK_NUMPAD7: case VK_NUMPAD8: case VK_NUMPAD9: { ascii_key = '0' + nChar - VK_NUMPAD0; } break;
default: { ToUnicode(nChar, MapVirtualKey(nChar, 0), keys, (LPWSTR)&ascii_key, 1,0); } } The KeyDown event is raised by a C# Windows Forms App.
MFC OnKeyDown's UINT nChar vs KeyEventArgs in c#
dustin1
private void control_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
switch(e.KeyCode)
{
case Keys.NumPad0:
case Keys.NumPad1:
case Keys.NumPad2:
case Keys.NumPad3:
case Keys.NumPad4:
case Keys.NumPad5:
case Keys.NumPad6:
case Keys.NumPad7:
case Keys.NumPad8:
case Keys.NumPad9:
{
char append = (char)(e.KeyCode - Keys.NumPad0);
ascii_key = string.Format( "0{0}", append );
}
}
}
Jenssa
void
KeyboardHandlers::OnKeyDown(HBaseViewClr^ hView, UINT nChar, bool bAlt){
switch (nChar) {
case VK_NUMPAD0:
case VK_NUMPAD1:
case VK_NUMPAD2:
case VK_NUMPAD3:
case VK_NUMPAD4:
case VK_NUMPAD5:
case VK_NUMPAD6:
case VK_NUMPAD7:
case VK_NUMPAD8:
case VK_NUMPAD9:
{
ascii_key = '0' + nChar - VK_NUMPAD0;
} break; default: {
ToUnicode(nChar, MapVirtualKey(nChar, 0), keys, (LPWSTR)&ascii_key, 1,0);
}
}
The KeyDown event is raised by a C# Windows Forms App.
Mats Upptrom