jwazmouse.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. // $Id: JwaZMOUSE.pas,v 1.5 2005/09/03 14:27:49 marquardt Exp $
  43. unit JwaZMOUSE;
  44. {$I jediapilib.inc}
  45. interface
  46. uses
  47. JwaWindows;
  48. {****************************************************************************
  49. * *
  50. * ZMOUSE.H -- Include file for IntelliMouse(tm) 1.0 *
  51. * *
  52. * NOTE: Zmouse.h contains #defines required when providing IntelliMouse *
  53. * wheel support for Windows95 and NT3.51. Wheel is supported *
  54. * natively in WinNT4.0, please refer to the NT4.0 SDK for more info *
  55. * on providing support for IntelliMouse in NT4.0. *
  56. * *
  57. * Copyright (c) 1983-1996, Microsoft Corp. All rights reserved. *
  58. * *
  59. \***************************************************************************}
  60. {**************************************************************************
  61. Client Application (API) Defines for Wheel rolling
  62. ***************************************************************************}
  63. // Apps need to call RegisterWindowMessage using the #define below to
  64. // get the message number that is sent to the foreground window
  65. // when a wheel roll occurs
  66. const
  67. {$IFDEF UNICODE}
  68. MSH_MOUSEWHEEL = WideString('MSWHEEL_ROLLMSG');
  69. {$EXTERNALSYM MSH_MOUSEWHEEL}
  70. {$ELSE}
  71. MSH_MOUSEWHEEL = 'MSWHEEL_ROLLMSG';
  72. {$EXTERNALSYM MSH_MOUSEWHEEL}
  73. {$ENDIF UNICODE}
  74. // wParam = wheel rotation expressed in multiples of WHEEL_DELTA
  75. // lParam is the mouse coordinates
  76. WHEEL_DELTA = 120; // Default value for rolling one notch
  77. {$EXTERNALSYM WHEEL_DELTA}
  78. WM_MOUSEWHEEL = WM_MOUSELAST + 1; // message that will be supported by the OS
  79. {$EXTERNALSYM WM_MOUSEWHEEL}
  80. {**************************************************************************
  81. Client Application (API) Defines for
  82. * determining if wheel support active
  83. * determining # of Scroll Lines
  84. ***************************************************************************}
  85. // Class name for MSWHEEL.EXE's invisible window
  86. // use FindWindow to get hwnd to MSWHEEL
  87. {$IFDEF UNICODE}
  88. MOUSEZ_CLASSNAME = WideString('MouseZ'); // wheel window class
  89. {$EXTERNALSYM MOUSEZ_CLASSNAME}
  90. MOUSEZ_TITLE = WideString('Magellan MSWHEEL'); // wheel window title
  91. {$EXTERNALSYM MOUSEZ_TITLE}
  92. {$ELSE}
  93. MOUSEZ_CLASSNAME = 'MouseZ'; // wheel window class
  94. {$EXTERNALSYM MOUSEZ_CLASSNAME}
  95. MOUSEZ_TITLE = 'Magellan MSWHEEL'; // wheel window title
  96. {$EXTERNALSYM MOUSEZ_TITLE}
  97. {$ENDIF UNICODE}
  98. MSH_WHEELMODULE_CLASS = MOUSEZ_CLASSNAME;
  99. {$EXTERNALSYM MSH_WHEELMODULE_CLASS}
  100. MSH_WHEELMODULE_TITLE = MOUSEZ_TITLE;
  101. {$EXTERNALSYM MSH_WHEELMODULE_TITLE}
  102. // Apps need to call RegisterWindowMessage using the #defines
  103. // below to get the message numbers for:
  104. // 1) the message that can be sent to the MSWHEEL window to
  105. // query if wheel support is active (MSH_WHEELSUPPORT)>
  106. // 2) the message to query for the number of scroll lines
  107. // (MSH_SCROLL_LINES)
  108. //
  109. // To send a message to MSWheel window, use FindWindow with the #defines
  110. // for CLASS and TITLE above. If FindWindow fails to find the MSWHEEL
  111. // window or the return from SendMessage is false, then Wheel support
  112. // is not currently available.
  113. {$IFDEF UNICODE}
  114. MSH_WHEELSUPPORT = WideString('MSH_WHEELSUPPORT_MSG'); // name of msg to send to query for wheel support
  115. {$EXTERNALSYM MSH_WHEELSUPPORT}
  116. {$ELSE}
  117. MSH_WHEELSUPPORT = 'MSH_WHEELSUPPORT_MSG'; // name of msg to send to query for wheel support
  118. {$EXTERNALSYM MSH_WHEELSUPPORT}
  119. {$ENDIF UNICODE}
  120. // MSH_WHEELSUPPORT
  121. // wParam - not used
  122. // lParam - not used
  123. // returns BOOL - TRUE if wheel support is active, FALSE otherwise
  124. {$IFDEF UNICODE}
  125. MSH_SCROLL_LINES = WideString('MSH_SCROLL_LINES_MSG');
  126. {$EXTERNALSYM MSH_SCROLL_LINES}
  127. {$ELSE}
  128. MSH_SCROLL_LINES = 'MSH_SCROLL_LINES_MSG';
  129. {$EXTERNALSYM MSH_SCROLL_LINES}
  130. {$ENDIF UNICODE}
  131. // MSH_SCROLL_LINES
  132. // wParam - not used
  133. // lParam - not used
  134. // returns int - number of lines to scroll on a wheel roll
  135. WHEEL_PAGESCROLL = UINT_MAX; // signifies to scroll a page, also
  136. // defined in winuser.h in the NT4.0 SDK
  137. {$EXTERNALSYM WHEEL_PAGESCROLL}
  138. SPI_SETWHEELSCROLLLINES = 105; // Also defined in winuser.h in the
  139. // NT4.0 SDK, please see the NT4.0 SDK
  140. // documentation for NT4.0 implementation
  141. // specifics.
  142. // For Win95 and WinNT3.51,
  143. // Mswheel broadcasts the message
  144. // WM_SETTINGCHANGE (equivalent to
  145. // WM_WININICHANGE) when the scroll
  146. // lines has changed. Applications
  147. // will recieve the WM_SETTINGCHANGE
  148. // message with the wParam set to
  149. // SPI_SETWHEELSCROLLLINES. When
  150. // this message is recieved the application
  151. // should query Mswheel for the new
  152. // setting.
  153. {$EXTERNALSYM SPI_SETWHEELSCROLLLINES}
  154. {*********************************************************************
  155. * INLINE FUNCTION: HwndMsWheel
  156. * Purpose : Get a reference to MSWheel Window, the registered messages,
  157. * wheel support active setting, and number of scrollLines
  158. * Params : PUINT puiMsh_MsgMouseWheel - address of UINT to contain returned registered wheel message
  159. * PUINT puiMsh_Msg3DSupport - address of UINT to contain wheel support registered message
  160. * PUINT puiMsh_MsgScrollLines - address of UINT to contain Scroll lines registered message
  161. * PBOOL pf3DSupport - address of BOOL to contain returned flag for wheel support active
  162. * PINT piScrollLines - address of int to contain returned scroll lines
  163. * Returns : HWND handle to the MsWheel window
  164. * Note : The return value for pf3DSupport and piScrollLines is dependant
  165. * on the POINT32 module. If POINT32 module is not running then
  166. * the values returned for these parameters will be
  167. * FALSE and 3, respectively.
  168. *********************************************************************}
  169. function HwndMSWheel(var puiMsh_MsgMouseWheel, puiMsh_Msg3DSupport,
  170. puiMsh_MsgScrollLines: UINT; var pf3DSupport: BOOL;
  171. var piScrollLines: Integer): HWND;
  172. {$EXTERNALSYM HwndMSWheel}
  173. implementation
  174. function HwndMSWheel(var puiMsh_MsgMouseWheel, puiMsh_Msg3DSupport,
  175. puiMsh_MsgScrollLines: UINT; var pf3DSupport: BOOL;
  176. var piScrollLines: Integer): HWND;
  177. begin
  178. Result := FindWindow(MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE);
  179. puiMsh_MsgMouseWheel := RegisterWindowMessage(MSH_MOUSEWHEEL);
  180. puiMsh_Msg3DSupport := RegisterWindowMessage(MSH_WHEELSUPPORT);
  181. puiMsh_MsgScrollLines := RegisterWindowMessage(MSH_SCROLL_LINES);
  182. if (puiMsh_Msg3DSupport <> 0) and (Result <> 0) then
  183. pf3DSupport := BOOL(SendMessage(Result, puiMsh_Msg3DSupport, 0, 0))
  184. else
  185. pf3DSupport := False; // default to FALSE
  186. if (puiMsh_MsgScrollLines <> 0) and (Result <> 0) then
  187. piScrollLines := SendMessage(Result, puiMsh_MsgScrollLines, 0, 0)
  188. else
  189. piScrollLines := 3; // default
  190. end;
  191. end.