Solved

Converting windows keypress to DOS scan code

Posted on 1997-09-10
5
695 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…

717 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