Solved

Converting windows keypress to DOS scan code

Posted on 1997-09-10
5
687 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
link access with Quickbooks 9 40
Alternative to visual sourcesafe 2 114
Clean Uninstall of VS Professional 2015 5 51
Please explain "Promise Pattern" and how it's used 2 54
This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now