mouse events and system("cls") problem
-
I've been using the following code and it works perfectly except for when I use the command "system("cls")" before using this code. How can I overcome that obstacle?
thanks in advanceThe code:
HANDLE hInput; INPUT_RECORD ir; unsigned long nEvents; printf("Hit Escape to view other stuff...\n\n"); hInput = GetStdHandle(STD_INPUT_HANDLE); while (1) { ReadConsoleInput(hInput, &ir, 1, &nEvents); if (ir.EventType == MOUSE_EVENT) { printf("Mouse Event: nEvents=%d x=%d y=%d button state=%ld\n", nEvents, ir.Event.MouseEvent.dwMousePosition.X, ir.Event.MouseEvent.dwMousePosition.Y, ir.Event.MouseEvent.dwButtonState); } else if (ir.EventType == KEY_EVENT) { printf("Keyboard Event: Events=%d bKeyDown=%d dwControlKeyState=%d" " uChar=%d wRepeatCount=%d wVirtualKeyCode=%d wVirtualScanCode=%d\n", nEvents, ir.Event.KeyEvent.bKeyDown, ir.Event.KeyEvent.dwControlKeyState, ir.Event.KeyEvent.uChar, ir.Event.KeyEvent.wRepeatCount, ir.Event.KeyEvent.wVirtualKeyCode, ir.Event.KeyEvent.wVirtualScanCode, ir.Event.MouseEvent.dwMousePosition.X, ir.Event.MouseEvent.dwMousePosition.Y, ir.Event.MouseEvent.dwButtonState); if (ir.Event.KeyEvent.wVirtualKeyCode == ESC) break; } else if (ir.EventType == FOCUS_EVENT) { printf("Focus Event: nEvents=%d bSetFocus=%d\n", nEvents, ir.Event.FocusEvent.bSetFocus); } } cout << "press a key..."; getch();
(please use cpp-Tags to highlight your codes - mfG CStoll)
-
The best solution would be, to avoid system("cls") completely
(btw, you should decide, whether you use C's printf()-Funktion or C++'s iostream's, but it's better not to mix them together)
-
10x
-
don't put your question in the title. nobody will read it.
-
ok...
so what can I use as a substitute for system("cls")?
-
-
I don't speak that lenguage so can someone please give me the answer in English?
Thank you all
-
copy the code from the website. it's in C. :p
-
Dieser Thread wurde von Moderator/in estartu aus dem Forum MFC (Visual C++) in das Forum DOS und Win32-Konsole verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.
-
thank you very much!
I succeeded doing so and the system("cls") worked as well!Thanks a lot everybody i'm grateful!!!
-
Hi, i have the same problem. Can you describe your solution?
thanks
-
Als Ergänzung:
How To Performing Clear Screen (CLS) in a Console Application
http://support.microsoft.com/support/kb/articles/q99/2/61.asp
-
Hm ice-man meinte ja, es mit dem system("cls") hinbekommen zu haben...
Die andere Sache mit void cls( HANDLE hConsole )
Damit komme ich nicht klar, was für ein handle soll ich denn übergeben, ich mein soll da ein "this" hin, immerhin ist es bei mir nur eine Consolenanwendung. Ich bin nicht ganz firm mit der Windowsprogrammierung...