jwazmouse.pas 11 KB

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