Solved

Converting windows keypress to DOS scan code

Posted on 1997-09-10
5
691 Views
Last Modified: 2013-12-03
I am converting a DOS program to Windows.  Most of the program is converted but the input has caused me a big problem.  I don't know how to convert a windows keypress message to a DOS scan code.  In the DOS version I use interupt x16.

The easiest change would be to use a function that would convert the windows WM_KEYUP and WM_KEYDOWN messages to DOS scan codes, as the rest of the program is written to use scan codes for input processing.

Is there a function which does this or is there a simple way to do the conversion?  I need to allow the key to remain down and also to keep the repeat count.

Thanks in advance for your help.

--Wulf
0
Comment
Question by:wulf
  • 3
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1406478
The WM_KEYDOWN and WM_KEYUP messages come with the scan code.

lKeyData = lParam;          // key data
16-23    Specifies the scan code. The value depends on the original equipment manufacturer (OEM).

Also, the OemKeyScan function maps OEM ASCII codes 0 through 0x0FF into the OEM scan codes and shift states.
0
 

Author Comment

by:wulf
ID: 1406479
I have read the help files and know about lParam.  What I need is an easy way to extract the information from it.  Are there any functions that will pull the scan code, repeat count and other information out of lParam?
0
 
LVL 23

Expert Comment

by:chensu
ID: 1406480
No, there aren't. You can use mask as follows:

BYTE byScanCode = (BYTE)(((DWORD)lParam & 0x00FF0000) >> 16);
0
 

Author Comment

by:wulf
ID: 1406481
The Scan Code works great.  Key Code is a problem.  The Key code recived from a Dos interupt differs from the windows returned value wParam.  In the application I am converting I need to have the Scan Code and the Key Code or facsimiles return the values as if it were receiving the information from a Dos interupt.

And example of the discrepencies are the arrow keys.  Dos return the value for a right arrow key as \xE0 or 224 and windows returns somthing else.

If you can help me in my quest, Thanks

--Wulf
0
 
LVL 23

Expert Comment

by:chensu
ID: 1406482
I think the only way to solve this is to create a translation table. When you receive the Windows key code, translate it to the DOS key code you want.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question