Solved

How to read Extended Keys?

Posted on 1997-03-27
6
315 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
[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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

728 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