Solved

How to read Extended Keys?

Posted on 1997-03-27
6
310 Views
Last Modified: 2010-05-18
I have Borland's Turbo C++ V4.5 and am trying to read extended keys, e.g. F1 - F12, etc., using "getch" and it doesn't work.  The exact same code in MS V C++ works just fine...What's up?
0
Comment
Question by:wmaes
  • 2
  • 2
  • 2
6 Comments
 

Expert Comment

by:Phoenix020397
ID: 1162496
The getch function returns a 0 and in the next time you run getch it automatically returns another number, special to that specific extended key. I recommend for you to build a program that reads a key, checks if it is 0, if it is then reads for the next key and then prints 0:next number. If the first number is not 0 then let it print just the number. That way you can learn the ascii value of the keys and the extended keys value.
0
 

Author Comment

by:wmaes
ID: 1162497
Phoenix,
  Your proposed solution is what I am doing; which is not working in Borland's Turbo C++ 4.5, but is working in MS Vis C++ with the same exact code.  I do one "getch()" and test for if it is equal to 0, and if so, I do a second "getch()" to determine which extended key was pressed.  In Borland, the "getch()" doesn't do anything when an extended key is pressed.  It's as if I didn't press anything.  But, in MS Vis C++, it reads the extended key just fine.  So...that's my question, what's up with that?
0
 

Expert Comment

by:Phoenix020397
ID: 1162498
I see, I'm sorry, I can't help you out with that one since I don't have your version of BC++. Sorry.
But, maybe your BC++ is malfunctioning, try reinstalling it or asking that question someone who has that same program but didn't get it from you.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 

Author Comment

by:wmaes
ID: 1162499
I don't know what else to try...I tried making the "target" an "application.exe", but that yielded some kind of owlMain error on linking.  The "easyWin" target option seems to be the only thing that produces an executeable, but it won't read the extended keys.
0
 
LVL 3

Accepted Solution

by:
LucHoltkamp earned 50 total points
ID: 1162500
Borlands 'EasyWin' is a shell that simulates a DOS-like console. But internally things are very different. Any keyboard input is first catched and processed by the shell and only certain keys are passed on to the 'getch' function.
Borland's 'EasyWin' and Microsofts 'EasyWin' are different, and Borland decided to filter out 'wrong' keys like the function-keys and ALT-key combination.
If you want to use function-keys you have to write a real Windows-program or use the DOS target.

You get a linker-error if you choose 'application' as target because you also choosed a Windows platform. A Windows-program must have a WinMain function (or OwlMain if you checked the 'OWL' checkbox), also you can't use 'getch' or other functions in <conio.h> in a Windows-program.
Try to use a 'application' target and 'DOS' platform.
0
 
LVL 3

Expert Comment

by:LucHoltkamp
ID: 1162501
I have the Borland 5.0 package, and it contains targets for every platform (DOS, WIN16 and WIN32), so when I read your question I assumed your package also supports all targets. But the TURBO 4.5 (not Borland 4.5) doesn't support all targets, but only the WIN16 target.
So if your compiler doesn't support DOS, maybe you've got the wrong compiler for your needs.
Perhaps this is a good time to start learning programming for Windows (in OWL). I can advise the book 'Programming with OWL for Windows' form Vic Broquard.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

820 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