Hi
can any one plaase tell me the VC++ (or Dev C++) equivalent of the getch() function (Turbo C++ under DOS). I am converting an old DOS based project to VC++ and Dev C++ consols application. but i found that the function getch() is showing different behavior. In Turbo C++ (under DOS) when i press Alt + F it was resulting in to a sequence of two numbers i.e ZERO and another numeric value. but in VC++ and Dev C++ it is returning the ascii value of 'F'.
so in short i want a function in VC++/Dev C++, which can detect and return values for such key combinations like Alt+KEY, Ctrl+KEY.
For more information please look at the code
Can any one change this function “int getKey()” below so that it can identify Key combination like Alt+f, Ctrl+f etc.
int isPrintable(int ch)
{
// Returns true if ch is a printable character
if(ch>126 || ch<32)
return false;
else
return true;
}
int getKey()
{
/*
This function need change as in case of Dev C++, Alt+Key, Ctrl+Key are producing
the same ASCII values as thet of the Key itself. Example Alt + f = f =102.
*/
int ch;
ch=getch();
if(isPrintable(ch)) // Ordinary key
return ch;
else
{
if(ch==224 || ch==0) // Special key
ch=getch();
ch+=1000; // Adding 1000 for special keys so that they can be identified
return ch;
}
}
Target:
Windows, VC++/Dev C++
Thanks