[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Converting windows keypress to DOS scan code

Posted on 1997-09-10
5
Medium Priority
?
703 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 100 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared 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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

656 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