sysmsg.pas 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. {
  2. Unit to handle system events
  3. Copyright 2000 by Pierre Muller <[email protected]>
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with this library; if not, write to the Free
  14. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************}
  16. Unit sysmsg;
  17. interface
  18. type
  19. TSystemMessage = (
  20. SysNothing,
  21. SysSetFocus,
  22. SysReleaseFocus,
  23. SysClose,
  24. SysResize );
  25. TSystemEvent = Record
  26. case typ : TSystemMessage of
  27. SysClose : ( CloseTyp : Longint);
  28. SysResize : (X,Y : Longint);
  29. end;
  30. PSystemEvent = ^TSystemEvent;
  31. const
  32. SystemEventBufSize = 16;
  33. var
  34. PendingSystemEvent : array[0..SystemEventBufSize-1] of TSystemEvent;
  35. PendingSystemHead,
  36. PendingSystemTail : PSystemEvent;
  37. PendingSystemEvents : byte;
  38. LastSystemEvent : TSystemEvent;
  39. procedure InitSystemMsg;
  40. procedure DoneSystemMsg;
  41. procedure GetSystemEvent(var SystemEvent:TSystemEvent);
  42. { Returns the last SystemEvent, and waits for one if not available }
  43. procedure PutSystemEvent(const SystemEvent: TSystemEvent);
  44. { Adds the given SystemEvent to the input queue. }
  45. function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
  46. { Checks if a SystemEvent is available, and returns it if one is found. If no
  47. event is pending, it returns 0 }
  48. implementation
  49. {$undef HAS_SYSMSG}
  50. {$ifdef go32v2}
  51. {$i go32smsg.inc}
  52. {$define HAS_SYSMSG}
  53. {$endif go32v2}
  54. {$ifdef win32}
  55. {$i w32smsg.inc}
  56. {$define HAS_SYSMSG}
  57. {$endif win32}
  58. {$ifdef unix}
  59. {$i unixsmsg.inc}
  60. {$define HAS_SYSMSG}
  61. {$endif unix}
  62. {$ifdef HAS_SYSMSG}
  63. procedure PutSystemEvent(const SystemEvent: TSystemEvent);
  64. begin
  65. if PendingSystemEvents<SystemEventBufSize then
  66. begin
  67. PendingSystemTail^:=SystemEvent;
  68. inc(PendingSystemTail);
  69. if longint(PendingSystemTail)=longint(@PendingSystemEvent)+sizeof(PendingSystemEvent) then
  70. PendingSystemTail:=@PendingSystemEvent;
  71. inc(PendingSystemEvents);
  72. end;
  73. end;
  74. {$else HAS_SYSMSG}
  75. procedure InitSystemMsg;
  76. begin
  77. end;
  78. procedure DoneSystemMsg;
  79. begin
  80. end;
  81. procedure GetSystemEvent(var SystemEvent:TSystemEvent);
  82. begin
  83. FillChar(SystemEvent,SizeOf(SystemEvent),#0);
  84. end;
  85. function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
  86. begin
  87. FillChar(SystemEvent,SizeOf(SystemEvent),#0);
  88. PollSystemEvent:=false;
  89. end;
  90. procedure PutSystemEvent(const SystemEvent: TSystemEvent);
  91. begin
  92. end;
  93. {$endif not HAS_SYSMSG}
  94. end.