program Project1;<br><br>{$APPTYPE CONSOLE}<br><br>uses<br> Windows, SysUtils;<br><br>var<br> hStdin: THANDLE;<br> cNumRead, fdwMode, fdwSaveOldMode, i: DWORD;<br> irInBuf: array[1..128] of INPUT_RECORD;<br> isExit : Boolean;<br><br> procedure PressAnyKeyToContinue(TipMsg: String);<br> begin<br> isExit := False;<br> write(TipMsg);<br> hStdin := GetStdHandle(STD_INPUT_HANDLE);<br> if hStdin = INVALID_HANDLE_VALUE then Exit;<br><br> if not GetConsoleMode(hStdin, fdwSaveOldMode) then Exit;<br><br> fdwMode := ENABLE_WINDOW_INPUT or ENABLE_MOUSE_INPUT;<br> if not SetConsoleMode(hStdin, fdwMode) then Exit;<br><br> while True do<br> begin<br><br> // Wait for the events.<br><br> if not ReadConsoleInput(<br> hStdin,<br> irInBuf[1],<br> 128,<br> cNumRead) then Exit;<br><br> // Dispatch the events to the appropriate handler.<br><br> for i := 0 to cNumRead do<br> begin<br> case irInBuf.EventType of<br> KEY_EVENT: // keyboard input<br> begin<br>// writeln('Keyboard event type');<br> isExit := True;<br> Break;<br> end;<br>{<br> _MOUSE_EVENT: // mouse input<br> writeln('mouse event type');<br><br> WINDOW_BUFFER_SIZE_EVENT: // scrn buf. resizing<br> writeln('buffer event type');<br><br> FOCUS_EVENT: // disregard focus events<br> writeln('focus event type');<br><br> MENU_EVENT: // disregard menu events<br> writeln('menu event type');<br><br> else<br> writeln('unknown event type');<br>}<br> end;<br> end;<br> if isExit then Break;<br> end;<br> SetConsoleMode(hStdin, fdwSaveOldMode);<br> end;<br><br>begin<br> { TODO -oUser -cConsole Main : Insert code here }<br><br> PressAnyKeyToContinue('Press Any Key To Continue...');<br><br>end.