Solved

How to read Extended Keys?

Posted on 1997-03-27
6
295 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

706 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

17 Experts available now in Live!

Get 1:1 Help Now