Solved

How to read Extended Keys?

Posted on 1997-03-27
6
300 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

911 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

20 Experts available now in Live!

Get 1:1 Help Now