testmou2.pas 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. program MouseTest;
  2. uses
  3. Crt, Mouse;
  4. var
  5. Event: TMouseEvent;
  6. begin
  7. while KeyPressed do ReadKey;
  8. WriteLn ('Mouse will be shown after any key');
  9. ReadKey;
  10. while KeyPressed do ReadKey;
  11. WriteLn ('Now generate mouse events or press any key to continue');
  12. InitMouse;
  13. while not (KeyPressed) do
  14. begin
  15. repeat until (KeyPressed) or PollMouseEvent (Event);
  16. if not (KeyPressed) then
  17. begin
  18. GetMouseEvent (Event);
  19. HideMouse;
  20. Write ('Buttons: ', Event.Buttons, ', X: ', Event.X, ', Y: ', Event.Y,
  21. ', action: ');
  22. case Event.Action of
  23. 0: WriteLn ('nothing');
  24. MouseActionDown: WriteLn ('down');
  25. MouseActionUp: WriteLn ('up');
  26. MouseActionMove: WriteLn ('move');
  27. else
  28. begin
  29. WriteLn ('undefined!!!');
  30. if ReadKey = #0 then ReadKey;
  31. end;
  32. end;
  33. ShowMouse;
  34. end;
  35. end;
  36. HideMouse;
  37. WriteLn ('Mouse will be hidden after any key');
  38. while KeyPressed do ReadKey;
  39. ShowMouse;
  40. if ReadKey = #0 then ReadKey;
  41. HideMouse;
  42. WriteLn ('Program ends after any key');
  43. if ReadKey = #0 then ReadKey;
  44. DoneMouse;
  45. end.