home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / zmouse.h < prev   
C/C++ Source or Header  |  1998-04-25  |  7KB  |  165 lines

  1. /****************************************************************************
  2. *                                                                           *
  3. * ZMOUSE.H -- Include file for IntelliMouse(tm) 1.0                         *
  4. *                                                                           *
  5. * NOTE:  Zmouse.h contains #defines required when providing IntelliMouse    *
  6. *        wheel support for Windows95 and NT3.51.  Wheel is supported        *
  7. *        natively in WinNT4.0, please refer to the NT4.0 SDK for more info  *
  8. *        on providing support for IntelliMouse in NT4.0.                    *
  9. *                                                                           *
  10. * Copyright (c) 1983-1996, Microsoft Corp. All rights reserved.             *
  11. *                                                                           *
  12. \***************************************************************************/
  13.  
  14.  
  15. /**************************************************************************
  16.      Client Appplication (API) Defines for Wheel rolling
  17. ***************************************************************************/
  18.  
  19.  
  20. // Apps need to call RegisterWindowMessage using the #define below to
  21. // get the message number that is sent to the foreground window
  22. // when a wheel roll occurs
  23.  
  24. #ifdef UNICODE
  25. #define MSH_MOUSEWHEEL L"MSWHEEL_ROLLMSG"
  26. #else
  27. #define MSH_MOUSEWHEEL "MSWHEEL_ROLLMSG"
  28. #endif
  29.    // wParam = wheel rotation expressed in multiples of WHEEL_DELTA
  30.    // lParam is the mouse coordinates
  31.  
  32. #define WHEEL_DELTA      120      // Default value for rolling one notch
  33.  
  34.  
  35. #ifndef WM_MOUSEWHEEL
  36. #define WM_MOUSEWHEEL (WM_MOUSELAST+1)  // message that will be supported
  37.                                         // by the OS 
  38. #endif
  39.  
  40.  
  41. /**************************************************************************
  42.     Client Appplication (API) Defines for
  43.        *  determining if wheel support active
  44.        *  determining # of Scroll Lines
  45. ***************************************************************************/
  46.  
  47. // Class name for MSWHEEL.EXE's invisible window 
  48. // use FindWindow to get hwnd to MSWHEEL
  49. #ifdef UNICODE
  50. #define MOUSEZ_CLASSNAME  L"MouseZ"           // wheel window class  
  51. #define MOUSEZ_TITLE      L"Magellan MSWHEEL" // wheel window title
  52. #else
  53. #define MOUSEZ_CLASSNAME  "MouseZ"            // wheel window class  
  54. #define MOUSEZ_TITLE      "Magellan MSWHEEL"  // wheel window title
  55. #endif
  56.  
  57. #define MSH_WHEELMODULE_CLASS (MOUSEZ_CLASSNAME)
  58. #define MSH_WHEELMODULE_TITLE (MOUSEZ_TITLE)
  59.  
  60. // Apps need to call RegisterWindowMessage using the #defines 
  61. // below to get the message numbers for:
  62. // 1) the message that can be sent to the MSWHEEL window to
  63. //    query if wheel support is active (MSH_WHEELSUPPORT)>
  64. // 2) the message to query for the number of scroll lines 
  65. //    (MSH_SCROLL_LINES)  
  66. //
  67. // To send a message to MSWheel window, use FindWindow with the #defines
  68. // for CLASS and TITLE above.  If FindWindow fails to find the MSWHEEL
  69. // window or the return from SendMessage is false, then Wheel support
  70. // is not currently available.
  71.  
  72. #ifdef UNICODE
  73. #define MSH_WHEELSUPPORT L"MSH_WHEELSUPPORT_MSG" // name of msg to send
  74.                                                  // to query for wheel support
  75. #else
  76. #define MSH_WHEELSUPPORT "MSH_WHEELSUPPORT_MSG"  // name of msg to send
  77.                                                  // to query for wheel support
  78. #endif
  79.  
  80. // MSH_WHEELSUPPORT
  81. //    wParam - not used 
  82. //    lParam - not used
  83. //    returns BOOL - TRUE if wheel support is active, FALSE otherwise
  84.  
  85.                                 
  86. #ifdef UNICODE
  87. #define MSH_SCROLL_LINES L"MSH_SCROLL_LINES_MSG"
  88. #else
  89. #define MSH_SCROLL_LINES "MSH_SCROLL_LINES_MSG"
  90. #endif
  91.  
  92. // MSH_SCROLL_LINES
  93. //    wParam - not used 
  94. //    lParam - not used
  95. //    returns int  - number of lines to scroll on a wheel roll
  96.  
  97. #ifndef  WHEEL_PAGESCROLL  
  98. #define WHEEL_PAGESCROLL  (UINT_MAX)   // signifies to scroll a page, also
  99.                                        // defined in winuser.h in the
  100.                                        // NT4.0 SDK
  101. #endif 
  102.  
  103. #ifndef SPI_SETWHEELSCROLLLINES
  104. #define SPI_SETWHEELSCROLLLINES   105  // Also defined in winuser.h in the
  105.                                        // NT4.0 SDK, please see the NT4.0 SDK
  106.                                        // documentation for NT4.0 implementation
  107.                                        // specifics.
  108.                                        // For Win95 and WinNT3.51, 
  109.                                        // Mswheel broadcasts the message
  110.                                        // WM_SETTINGCHANGE (equivalent to
  111.                                        // WM_WININICHANGE) when the scroll
  112.                                        // lines has changed.  Applications
  113.                                        // will recieve the WM_SETTINGCHANGE
  114.                                        // message with the wParam set to
  115.                                        // SPI_SETWHEELSCROLLLINES.  When
  116.                                        // this message is recieved the application
  117.                                        // should query Mswheel for the new 
  118.                                        // setting.
  119. #endif
  120.  
  121.  
  122. /*********************************************************************
  123. * INLINE FUNCTION: HwndMsWheel
  124. * Purpose : Get a reference to MSWheel Window, the registered messages,  
  125. *           wheel support active setting, and number of scrollLines
  126. * Params  : PUINT puiMsh_MsgMouseWheel - address of UINT to contain returned registered wheel message
  127. *           PUINT puiMsh_Msg3DSupport - address of UINT to contain wheel support registered message
  128. *           PUINT puiMsh_MsgScrollLines - address of UINT to contain Scroll lines registered message
  129. *           PBOOL pf3DSupport - address of BOOL to contain returned flag for wheel support active
  130. *           PINT  piScrollLines - address of int to contain returned scroll lines
  131. * Returns : HWND handle to the MsWheel window
  132. * Note    : The return value for pf3DSupport and piScrollLines is dependant
  133. *           on the POINT32 module.  If POINT32 module is not running then
  134. *           the values returned for these parameters will be
  135. *           FALSE and 3, respectively. 
  136. *********************************************************************/
  137. __inline HWND HwndMSWheel( 
  138.       PUINT puiMsh_MsgMouseWheel,
  139.       PUINT puiMsh_Msg3DSupport,
  140.       PUINT puiMsh_MsgScrollLines,
  141.       PBOOL pf3DSupport,
  142.       PINT  piScrollLines
  143. )
  144. {
  145.    HWND hdlMsWheel;
  146.  
  147.    hdlMsWheel = FindWindow(MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE);
  148.  
  149.    *puiMsh_MsgMouseWheel = RegisterWindowMessage(MSH_MOUSEWHEEL);
  150.    *puiMsh_Msg3DSupport = RegisterWindowMessage(MSH_WHEELSUPPORT);
  151.    *puiMsh_MsgScrollLines = RegisterWindowMessage(MSH_SCROLL_LINES);
  152.  
  153.    if (*puiMsh_Msg3DSupport)
  154.       *pf3DSupport = (BOOL)SendMessage(hdlMsWheel, *puiMsh_Msg3DSupport, 0, 0);
  155.    else
  156.       *pf3DSupport = FALSE;  // default to FALSE
  157.  
  158.    if (*puiMsh_MsgScrollLines)
  159.       *piScrollLines = (int)SendMessage(hdlMsWheel, *puiMsh_MsgScrollLines, 0, 0);
  160.    else
  161.       *piScrollLines = 3;  // default
  162.  
  163.    return(hdlMsWheel);
  164. }
  165.