mouse9.pp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. {example for SetMouseHideWindow}
  2. {warning: when the mouse is moved into the specified region, it is turned off
  3. until you call ShowMouse again. However, when you've called ShowMouse,
  4. you'll have to call SetMouseHideWindow again to redefine the hide window...
  5. It's not our fault, that's the way it's implemented in the mouse driver.
  6. Below you can find an example of how to define a "permanent" hide region
  7. with the cursor showing up again when you move it out of the region
  8. Note: the mouse functions are zero-based, GotoXY is 1-based}
  9. Uses MsMouse, Crt;
  10. Var x, y, buttons: Longint;
  11. MouseOn: Boolean;
  12. Begin
  13. If MouseFound Then
  14. Begin
  15. ClrScr;
  16. For y := 1 to 25 Do
  17. Begin
  18. GotoXY(20,y);
  19. Write('|');
  20. GotoXY(60,y);
  21. Write('|');
  22. End;
  23. MouseOn := true;
  24. GotoXY(30, 24);
  25. Writeln('Press any key to quit');
  26. ShowMouse;
  27. SetMousePos(1,1);
  28. While KeyPressed Do Readkey;
  29. Repeat
  30. GetMouseState(x,y,buttons);
  31. If Not(MouseOn) And
  32. ((x <= 19*8) or (x >= 59*8)) Then
  33. Begin
  34. ShowMouse;
  35. MouseOn := true
  36. End;
  37. If MouseOn And (x > 19*8) And (x<59*8) Then
  38. Begin
  39. SetMouseHideWindow(20*8,0,60*8,25*8);
  40. MouseOn := false
  41. End;
  42. Until KeyPressed;
  43. While KeyPressed Do Readkey;
  44. HideMouse
  45. End
  46. End.