ReadConsole test to show how backspaces should be handled.
authorBrandon Turner <turnerb7@msu.edu>
Thu, 8 Jun 2006 12:59:32 +0000 (12:59 +0000)
committerBrandon Turner <turnerb7@msu.edu>
Thu, 8 Jun 2006 12:59:32 +0000 (12:59 +0000)
svn path=/trunk/; revision=22282

rosapps/tests/directory.xml
rosapps/tests/readconsole/main.c [new file with mode: 0644]
rosapps/tests/readconsole/readconsole.rbuild [new file with mode: 0644]

index 88b5ae7..978c27c 100644 (file)
        <xi:include href="p_dup_handle/p_dup_handle.xml" />
 </directory>
 
+<directory name="readconsole">
+       <xi:include href="readconsole/readconsole.rbuild" />
+</directory>
+
 <!-- fixme: regdump -->
 
 <directory name="regqueryvalue">
diff --git a/rosapps/tests/readconsole/main.c b/rosapps/tests/readconsole/main.c
new file mode 100644 (file)
index 0000000..2d85553
--- /dev/null
@@ -0,0 +1,32 @@
+#include "stdio.h"\r
+#include "Windows.h"\r
+\r
+int main()\r
+{\r
+    TCHAR Buffer = 0;\r
+    DWORD Count = 0;\r
+\r
+    //\r
+    // We clear the mode, most importantly turn off ENABLE_ECHO_INPUT and ENABLE_LINE_INPUT\r
+    // This is the same mode as that is set up by getch() when trying to get a char\r
+    //\r
+    SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),0);\r
+\r
+    //\r
+    // We read one char from the input and then return\r
+    //\r
+    ReadConsole(GetStdHandle(STD_INPUT_HANDLE),&Buffer,1,&Count,NULL);\r
+\r
+    //\r
+    // We print out this char as an int to show that infact a backspace does count as input\r
+    //\r
+    printf("You printed %c :: ", Buffer);\r
+    printf("With a value %d :: ", Buffer);\r
+    printf("Number of chars recieved %lu :: ", Count);\r
+    printf("Char equal to backspace %d \n", (Buffer == '\b'));\r
+\r
+    //\r
+    // :)\r
+    //\r
+    return 0;\r
+}\r
diff --git a/rosapps/tests/readconsole/readconsole.rbuild b/rosapps/tests/readconsole/readconsole.rbuild
new file mode 100644 (file)
index 0000000..1542622
--- /dev/null
@@ -0,0 +1,5 @@
+<module name="readconsole" type="win32cui" installbase="bin" installname="readconsole.exe">\r
+       <define name="__USE_W32API" />\r
+       <library>kernel32</library>\r
+       <file>main.c</file>\r
+</module>\r