Getting user input from Win32 C++. WPARAM casted as int?

I'm working on a pre-existing codebase and I'm looking to have the user type any 1-2 digits followed by the enter key at any time during the code being run and pass that number to a function. Currently, user input is handled like so:

    int wmId, wmEvent;

    switch (message)
    case WM_KEYDOWN:

Now, I'm not sure of a few things,

  • a) Why would the keypressed be passed as an integer rather than a character?

  • b) What would be the result of "F1" being sent in this case aaand

  • c) How can I use this to read in a 1-2 digit number and pass that only when enter is pressed?


a) The value sent here is a virtual-key code, not necessarily a character.

b) See list of virtual key codes here (given in a comment). F1 would be represented by VK_F1 (0x70).

c) When a digit is pressed, add it to a string containing the last digit presses. When any other key is pressed, clear the string. When enter is pressed, act based on the string value.

Edit: This would be a bit complicated in WM_KEYDOWN since you would need to handle both the normal digit keys and the numpad keys. It will be easier to handle the WM_CHAR message instead, which receives the character code in wParam.

Need Your Help

ReSharper 5 installer not recognizing Visual Studio 2010 Express

ide visual-studio-2010 resharper

I'm trying to install ReSharper 5. But the installer does not recognize that I've got Visual Studio 2010 Express installed. The installer does find my Visual Studio 2008 Team System installation.