Solved

Converting windows keypress to DOS scan code

Posted on 1997-09-10
5
685 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
Comment Utility
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
Comment Utility
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
Comment Utility
No, there aren't. You can use mask as follows:

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

Author Comment

by:wulf
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

6 Experts available now in Live!

Get 1:1 Help Now