Capture all keyboard input inside a dialog
-
Hi, I have a dialog will get input from a 2D barcode scanner, about a couple hundred characters. I already override the PreTranslateMessage but still not sure what's best way to capture the scanner input as stdin. I think my problem is that I am not too familiar with Windows messaging. So, When I got a lot messages inside PreTranslateMessage, I don't know how to filter out & convert the data I want. Can someone give me some suggestions? Thanks, Kevin
-
Hi, I have a dialog will get input from a 2D barcode scanner, about a couple hundred characters. I already override the PreTranslateMessage but still not sure what's best way to capture the scanner input as stdin. I think my problem is that I am not too familiar with Windows messaging. So, When I got a lot messages inside PreTranslateMessage, I don't know how to filter out & convert the data I want. Can someone give me some suggestions? Thanks, Kevin
I'm not sure what you're asking....Does the scanner input come in a keyboard messages? Steve
-
Hi, I have a dialog will get input from a 2D barcode scanner, about a couple hundred characters. I already override the PreTranslateMessage but still not sure what's best way to capture the scanner input as stdin. I think my problem is that I am not too familiar with Windows messaging. So, When I got a lot messages inside PreTranslateMessage, I don't know how to filter out & convert the data I want. Can someone give me some suggestions? Thanks, Kevin
kevincwong wrote:
Capture all keyboard input inside a dialog
You can do this by overriding PreTranslateMessage append this code inside your PreTranslateMessage handler.
if(pMsg->message == WM_KEYDOWN) { //now the key pressed is available in //pMsg->wParam... store it in a string or //character variable and write it to a file }
Regards, Rajesh R. Subramanian You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.
-
Hi, I have a dialog will get input from a 2D barcode scanner, about a couple hundred characters. I already override the PreTranslateMessage but still not sure what's best way to capture the scanner input as stdin. I think my problem is that I am not too familiar with Windows messaging. So, When I got a lot messages inside PreTranslateMessage, I don't know how to filter out & convert the data I want. Can someone give me some suggestions? Thanks, Kevin
Use GetWindowLong/SetWindowLong to change the Dialog proc to ur own custome made window proc. U can handle messages of ur interest, let the rest will be handled by defaultwindowproc
-
kevincwong wrote:
Capture all keyboard input inside a dialog
You can do this by overriding PreTranslateMessage append this code inside your PreTranslateMessage handler.
if(pMsg->message == WM_KEYDOWN) { //now the key pressed is available in //pMsg->wParam... store it in a string or //character variable and write it to a file }
Regards, Rajesh R. Subramanian You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.
Rajesh, Great! that's exactly what I want. I know I read it from somewhere before but just can not remember how to do so. btw, when I pressed a key (for example 'a', the pMsg->wParm is 65, ']' is 221), I think the pMsg->wParm is the scancode (not ASCII code). Am I correct? Thank for you help!! Kevin
-
Rajesh, Great! that's exactly what I want. I know I read it from somewhere before but just can not remember how to do so. btw, when I pressed a key (for example 'a', the pMsg->wParm is 65, ']' is 221), I think the pMsg->wParm is the scancode (not ASCII code). Am I correct? Thank for you help!! Kevin
kevincwong wrote:
btw, when I pressed a key (for example 'a', the pMsg->wParm is 65, ']' is 221), I think the pMsg->wParm is the scancode (not ASCII code).
No, in the cases of the normal non-special keys, the values will be the ASCII codes for the keyboard key pressed (not the actual character received). So when you press
<A>
on the keyboard, you get a value of65
, which is the same as'A'
. This should be the code received regardless of things like SHIFT or CTRL key state. Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!) -
kevincwong wrote:
btw, when I pressed a key (for example 'a', the pMsg->wParm is 65, ']' is 221), I think the pMsg->wParm is the scancode (not ASCII code).
No, in the cases of the normal non-special keys, the values will be the ASCII codes for the keyboard key pressed (not the actual character received). So when you press
<A>
on the keyboard, you get a value of65
, which is the same as'A'
. This should be the code received regardless of things like SHIFT or CTRL key state. Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!)Hi James, That's what I guess with alphanumeric character, like 'A'. But it does not explain ']' (pMsg->Param == 221). The ASCII for for ']' is 93. It looks like 221 - 128 = 93. Do you know why? Thanks, Kevin
-
Hi James, That's what I guess with alphanumeric character, like 'A'. But it does not explain ']' (pMsg->Param == 221). The ASCII for for ']' is 93. It looks like 221 - 128 = 93. Do you know why? Thanks, Kevin
Hmmm! No idea. Maybe different local/keyboard settings than standard US-English? Maybe using
MapVirtualKeyEx(...)
with a MapType of2
would help here? Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!) -
Hi James, That's what I guess with alphanumeric character, like 'A'. But it does not explain ']' (pMsg->Param == 221). The ASCII for for ']' is 93. It looks like 221 - 128 = 93. Do you know why? Thanks, Kevin
Hi Kevin, When some key is pressed, the value that arrives at
pMsg->wParam
will be equal to the Virtual Key code of that particular key. Please look up MSDN for more details about Virtual Key Codes. Say, for example, when the 'p' key is pressed, the value that arrives will be equal to
VK_P
which is the virtual key code of that key. If you need to know upper/lowercase detail too, use the
GetKeyState()
function to know if shift key is pressed or if CAPS LOCK is turned on. Please let me know if this solved your problem. Regards, Rajesh R. Subramanian You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.
-
Hi Kevin, When some key is pressed, the value that arrives at
pMsg->wParam
will be equal to the Virtual Key code of that particular key. Please look up MSDN for more details about Virtual Key Codes. Say, for example, when the 'p' key is pressed, the value that arrives will be equal to
VK_P
which is the virtual key code of that key. If you need to know upper/lowercase detail too, use the
GetKeyState()
function to know if shift key is pressed or if CAPS LOCK is turned on. Please let me know if this solved your problem. Regards, Rajesh R. Subramanian You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.
Got it! Thanks, Kevin