winapi - Getting user input from Win32 C++. WPARAM casted as int? -
I am working on a pre-existing codebase and I follow any 1-2 digits of user type When entering the code at any time by entering the key and passing that number to a function. At present, user input is controlled in such a way:
LRESULT callback WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {int wmId, wmEvent; Switch (Message) {Case WM_KEYDOWN: Engine :: GetInstance () - & gt; GetInput () - & gt; GetKeyboard () - & gt; Setcased (static_cast & lt; int & gt; (wParam)); break; // Content
Now, I do not know about some things,
-
a) Why pass cubes as an integer Will instead be a character?
-
b) In this case what will be the "F1" sent
-
c) How can I do this? Use it to read in the 1-2 digit number and only when the entry is entered?
a) The value sent here is a virtual-key code, required Not a letter
b) See the list of virtual key codes (given in a comment) F1 will be represented by VK_F1 (0x70).
c) When a number is pressed, add it to a string, which includes the last digit press. When any other key is pressed, clear the string. When the entry is entered, the string works by value.
Edit : This will be a bit complicated in WM_KEYDOWN
because you will need to handle both common points and numpad keys instead of WM_CHAR
message will be easy to handle, which receives the character code in wParam.
Comments
Post a Comment