|
-
Dec 7th, 2003, 01:46 PM
#1
Thread Starter
Addicted Member
wide-character getch ()
Is there a wide-character version of C's getch () function? I've tried getwchar () but it doesn't seem to work
Using Visual Studio .NET 2005
-
Dec 7th, 2003, 02:38 PM
#2
Hyperactive Member
what do u mean by wide-character version of getch()
use scanf or gets for getting more than 1 character
-
Dec 7th, 2003, 04:30 PM
#3
Thread Starter
Addicted Member
I mean something like getch () which will return a WCHAR. I need to detect arrow key presses, and while I know how to interpret them (a leading NULL character) it seems bet to just use a WCHAR.
So far, I'm using the following function, but I'd much prefer a standard function:
Code:
WCHAR CConsole::ReadKey ()
{
if (!kbhit ()) return 0;
char lowCh = getch ();
if ((lowCh == -32) || (lowCh == 0)) // Arrow key or Function key
return ((getch () << 8) + lowCh);
else
return (WCHAR) lowCh;
}
Using Visual Studio .NET 2005
-
Dec 7th, 2003, 04:39 PM
#4
_getwch
getch is a wrong name btw, it should be _getch.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 7th, 2003, 05:15 PM
#5
Thread Starter
Addicted Member
there's nothing in the MSDN library about _getwch () and I'm unable to use it (Undeclared Identifier).
Do I have to include a specific header? I've tried to find this myself, but everywhere say to use <conio.h> which doesn't work either.
Last edited by Barguast; Dec 7th, 2003 at 05:22 PM.
Using Visual Studio .NET 2005
-
Dec 8th, 2003, 04:26 AM
#6
Hyperactive Member
why getch is a correct name and u need to include conio.h
-
Dec 8th, 2003, 04:27 AM
#7
Hyperactive Member
Barguast
U can use keyboard interrupts to get the scan code for each key.U know that each key(including entre,F1......F12) have a unique scan code . u can use that..
for this use int86 function..
-
Dec 8th, 2003, 04:41 AM
#8
getch is a non-ANSI function. Therefore it should be prefixed with _. I believe MS does that, but it also provides the non-conforming name getch for compatibility with older apps, unless you enforce ANSI compatibility with the /Za compiler switch.
_getch and _getwch are documented in my VS.Net 2003.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 8th, 2003, 07:36 AM
#9
Thread Starter
Addicted Member
Originally posted by sw_is_great
u need to include conio.h
I'm still getting an 'undeclared identifier' error when i include this... I'm using MS Visual Studio 6.0 - could I have an outdated header file or something?
Using Visual Studio .NET 2005
-
Dec 9th, 2003, 08:47 AM
#10
Hyperactive Member
post ur code
should be something like
#include<stdio.h>
#include<conio.h>
main()
{
printf("\n Screen wait for me");
getch();
}
-
Dec 9th, 2003, 01:32 PM
#11
Thread Starter
Addicted Member
it's not _getch () I've got a problem with, it's _getwch ().
Having tried the code you posted, but using _getwch () instead, I still get an undeclared identifier error for using _getwch ().
Using Visual Studio .NET 2005
-
Dec 10th, 2003, 03:19 AM
#12
Hyperactive Member
For trapping keyboard hits including enter key etc , use keyboard interrupts -
they are fast
reliable
-
Dec 13th, 2003, 09:52 AM
#13
...and don't work in real Win32 apps.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|