ex6.pp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. Program Example6;
  2. { Program to demonstrate the PollMouseEvent function. }
  3. Uses mouse;
  4. Procedure DumpEvent(Const Event : TMouseEvent);
  5. begin
  6. With event do
  7. begin
  8. Write('Action:');
  9. Case Action of
  10. MouseActionDown : Write('Mouse down.');
  11. MouseActionUp : Write('Mouse up.');
  12. MouseActionMove : Write('Mouse move.');
  13. end;
  14. Write('Button state : ');
  15. If (Buttons and MouseLeftbutton)<>0 then
  16. Write('Left ');
  17. If (Buttons and MouseRightbutton)<>0 then
  18. Write('Right ');
  19. If (Buttons and MouseMiddlebutton)<>0 then
  20. Write('Middle ');
  21. Write('Button(s)');
  22. Writeln(' at ',X,',',Y,'.');
  23. end;
  24. end;
  25. Var
  26. Event : TMouseEvent;
  27. begin
  28. InitMouse;
  29. Writeln('Play with mouse. Press right mouse button to end.');
  30. Repeat
  31. If PollMouseEvent(Event)Then
  32. begin
  33. DumpEvent(Event);
  34. GetMouseEvent(Event);
  35. end
  36. else
  37. Write('.');
  38. Until (Event.Buttons=MouseRightButton) and
  39. (Event.Action=MouseActionDown);
  40. DoneMouse;
  41. end.