jwazmouse.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. {******************************************************************************}
  2. { }
  3. { Intellimouse API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: zmouse.h, released June 2000. The original Pascal }
  9. { code is: ZMOUSE.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. unit JwaZMOUSE;
  43. {$I jediapilib.inc}
  44. interface
  45. uses
  46. JwaWinUser, JwaWinType;
  47. {****************************************************************************
  48. * *
  49. * ZMOUSE.H -- Include file for IntelliMouse(tm) 1.0 *
  50. * *
  51. * NOTE: Zmouse.h contains #defines required when providing IntelliMouse *
  52. * wheel support for Windows95 and NT3.51. Wheel is supported *
  53. * natively in WinNT4.0, please refer to the NT4.0 SDK for more info *
  54. * on providing support for IntelliMouse in NT4.0. *
  55. * *
  56. * Copyright (c) 1983-1996, Microsoft Corp. All rights reserved. *
  57. * *
  58. \***************************************************************************}
  59. {**************************************************************************
  60. Client Application (API) Defines for Wheel rolling
  61. ***************************************************************************}
  62. // Apps need to call RegisterWindowMessage using the #define below to
  63. // get the message number that is sent to the foreground window
  64. // when a wheel roll occurs
  65. const
  66. {$IFDEF UNICODE}
  67. MSH_MOUSEWHEEL = WideString('MSWHEEL_ROLLMSG');
  68. {$EXTERNALSYM MSH_MOUSEWHEEL}
  69. {$ELSE}
  70. MSH_MOUSEWHEEL = 'MSWHEEL_ROLLMSG';
  71. {$EXTERNALSYM MSH_MOUSEWHEEL}
  72. {$ENDIF UNICODE}
  73. // wParam = wheel rotation expressed in multiples of WHEEL_DELTA
  74. // lParam is the mouse coordinates
  75. WHEEL_DELTA = 120; // Default value for rolling one notch
  76. {$EXTERNALSYM WHEEL_DELTA}
  77. WM_MOUSEWHEEL = WM_MOUSELAST + 1; // message that will be supported by the OS
  78. {$EXTERNALSYM WM_MOUSEWHEEL}
  79. {**************************************************************************
  80. Client Application (API) Defines for
  81. * determining if wheel support active
  82. * determining # of Scroll Lines
  83. ***************************************************************************}
  84. // Class name for MSWHEEL.EXE's invisible window
  85. // use FindWindow to get hwnd to MSWHEEL
  86. {$IFDEF UNICODE}
  87. MOUSEZ_CLASSNAME = WideString('MouseZ'); // wheel window class
  88. {$EXTERNALSYM MOUSEZ_CLASSNAME}
  89. MOUSEZ_TITLE = WideString('Magellan MSWHEEL'); // wheel window title
  90. {$EXTERNALSYM MOUSEZ_TITLE}
  91. {$ELSE}
  92. MOUSEZ_CLASSNAME = 'MouseZ'; // wheel window class
  93. {$EXTERNALSYM MOUSEZ_CLASSNAME}
  94. MOUSEZ_TITLE = 'Magellan MSWHEEL'; // wheel window title
  95. {$EXTERNALSYM MOUSEZ_TITLE}
  96. {$ENDIF UNICODE}
  97. MSH_WHEELMODULE_CLASS = MOUSEZ_CLASSNAME;
  98. {$EXTERNALSYM MSH_WHEELMODULE_CLASS}
  99. MSH_WHEELMODULE_TITLE = MOUSEZ_TITLE;
  100. {$EXTERNALSYM MSH_WHEELMODULE_TITLE}
  101. // Apps need to call RegisterWindowMessage using the #defines
  102. // below to get the message numbers for:
  103. // 1) the message that can be sent to the MSWHEEL window to
  104. // query if wheel support is active (MSH_WHEELSUPPORT)>
  105. // 2) the message to query for the number of scroll lines
  106. // (MSH_SCROLL_LINES)
  107. //
  108. // To send a message to MSWheel window, use FindWindow with the #defines
  109. // for CLASS and TITLE above. If FindWindow fails to find the MSWHEEL
  110. // window or the return from SendMessage is false, then Wheel support
  111. // is not currently available.
  112. {$IFDEF UNICODE}
  113. MSH_WHEELSUPPORT = WideString('MSH_WHEELSUPPORT_MSG'); // name of msg to send to query for wheel support
  114. {$EXTERNALSYM MSH_WHEELSUPPORT}
  115. {$ELSE}
  116. MSH_WHEELSUPPORT = 'MSH_WHEELSUPPORT_MSG'; // name of msg to send to query for wheel support
  117. {$EXTERNALSYM MSH_WHEELSUPPORT}
  118. {$ENDIF UNICODE}
  119. // MSH_WHEELSUPPORT
  120. // wParam - not used
  121. // lParam - not used
  122. // returns BOOL - TRUE if wheel support is active, FALSE otherwise
  123. {$IFDEF UNICODE}
  124. MSH_SCROLL_LINES = WideString('MSH_SCROLL_LINES_MSG');
  125. {$EXTERNALSYM MSH_SCROLL_LINES}
  126. {$ELSE}
  127. MSH_SCROLL_LINES = 'MSH_SCROLL_LINES_MSG';
  128. {$EXTERNALSYM MSH_SCROLL_LINES}
  129. {$ENDIF UNICODE}
  130. // MSH_SCROLL_LINES
  131. // wParam - not used
  132. // lParam - not used
  133. // returns int - number of lines to scroll on a wheel roll
  134. WHEEL_PAGESCROLL = UINT_MAX; // signifies to scroll a page, also
  135. // defined in winuser.h in the NT4.0 SDK
  136. {$EXTERNALSYM WHEEL_PAGESCROLL}
  137. SPI_SETWHEELSCROLLLINES = 105; // Also defined in winuser.h in the
  138. // NT4.0 SDK, please see the NT4.0 SDK
  139. // documentation for NT4.0 implementation
  140. // specifics.
  141. // For Win95 and WinNT3.51,
  142. // Mswheel broadcasts the message
  143. // WM_SETTINGCHANGE (equivalent to
  144. // WM_WININICHANGE) when the scroll
  145. // lines has changed. Applications
  146. // will recieve the WM_SETTINGCHANGE
  147. // message with the wParam set to
  148. // SPI_SETWHEELSCROLLLINES. When
  149. // this message is recieved the application
  150. // should query Mswheel for the new
  151. // setting.
  152. {$EXTERNALSYM SPI_SETWHEELSCROLLLINES}
  153. {*********************************************************************
  154. * INLINE FUNCTION: HwndMsWheel
  155. * Purpose : Get a reference to MSWheel Window, the registered messages,
  156. * wheel support active setting, and number of scrollLines
  157. * Params : PUINT puiMsh_MsgMouseWheel - address of UINT to contain returned registered wheel message
  158. * PUINT puiMsh_Msg3DSupport - address of UINT to contain wheel support registered message
  159. * PUINT puiMsh_MsgScrollLines - address of UINT to contain Scroll lines registered message
  160. * PBOOL pf3DSupport - address of BOOL to contain returned flag for wheel support active
  161. * PINT piScrollLines - address of int to contain returned scroll lines
  162. * Returns : HWND handle to the MsWheel window
  163. * Note : The return value for pf3DSupport and piScrollLines is dependant
  164. * on the POINT32 module. If POINT32 module is not running then
  165. * the values returned for these parameters will be
  166. * FALSE and 3, respectively.
  167. *********************************************************************}
  168. function HwndMSWheel(var puiMsh_MsgMouseWheel, puiMsh_Msg3DSupport,
  169. puiMsh_MsgScrollLines: UINT; var pf3DSupport: BOOL;
  170. var piScrollLines: Integer): HWND;
  171. {$EXTERNALSYM HwndMSWheel}
  172. implementation
  173. function HwndMSWheel(var puiMsh_MsgMouseWheel, puiMsh_Msg3DSupport,
  174. puiMsh_MsgScrollLines: UINT; var pf3DSupport: BOOL;
  175. var piScrollLines: Integer): HWND;
  176. begin
  177. Result := FindWindow(MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE);
  178. puiMsh_MsgMouseWheel := RegisterWindowMessage(MSH_MOUSEWHEEL);
  179. puiMsh_Msg3DSupport := RegisterWindowMessage(MSH_WHEELSUPPORT);
  180. puiMsh_MsgScrollLines := RegisterWindowMessage(MSH_SCROLL_LINES);
  181. if (puiMsh_Msg3DSupport <> 0) and (Result <> 0) then
  182. pf3DSupport := BOOL(SendMessage(Result, puiMsh_Msg3DSupport, 0, 0))
  183. else
  184. pf3DSupport := False; // default to FALSE
  185. if (puiMsh_MsgScrollLines <> 0) and (Result <> 0) then
  186. piScrollLines := SendMessage(Result, puiMsh_MsgScrollLines, 0, 0)
  187. else
  188. piScrollLines := 3; // default
  189. end;
  190. end.