home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / intelli.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.6 KB  |  105 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include "stdafx.h"
  20. #include "intelli.h"
  21. #include "slavewnd.h"
  22.  
  23. //  Be sure to handle WM_MOUSEWHEEL and this registered message
  24. //      also.
  25. UINT msg_MouseWheel =
  26. #if _MSC_VER >= 1100
  27.     RegisterWindowMessage(MSH_MOUSEWHEEL);
  28. #else
  29.     (UINT)-1;
  30. #endif
  31.  
  32. //  Internal to this file.
  33. UINT msg_ScrollLines =
  34. #if _MSC_VER >= 1100
  35.     RegisterWindowMessage(MSH_SCROLL_LINES);
  36. #else
  37.     (UINT)-1;
  38. #endif
  39.  
  40. CMouseWheel intelli;
  41.  
  42. void UpdateMouseSettings(UINT uMsg, WPARAM wParam, LPARAM lParam)
  43. {
  44.     //  Make sure we want to take a look at this.
  45.     if(uMsg == WM_SETTINGCHANGE)    {
  46.         //  What happened?
  47. #if _MSC_VER >= 1100
  48.         if(wParam == SPI_SETWHEELSCROLLLINES)   {
  49.             //  Number of scroll lines changed.
  50.             intelli.Update();
  51.         }
  52. #endif
  53.     }
  54. }
  55.  
  56. CMouseWheel::CMouseWheel()
  57. {
  58.     m_uScrollLines = 0;
  59.  
  60.     //  Initialize mouse settings.
  61.     Update();
  62.  
  63.     //  Register to watch mouse settings.
  64.     m_pWatcher = slavewnd.Register(WM_SETTINGCHANGE, UpdateMouseSettings);
  65. }
  66.  
  67. CMouseWheel::~CMouseWheel()
  68. {
  69.     if(m_pWatcher)  {
  70.         slavewnd.UnRegister(m_pWatcher);
  71.         m_pWatcher = NULL;
  72.     }
  73. }
  74.  
  75. void CMouseWheel::Update()
  76. {
  77.     HWND hWheel = GetWheelWnd();
  78.  
  79.     //  Determine number of lines to scroll.
  80.     m_uScrollLines = 3;
  81.  
  82.     if(sysInfo.m_bWinNT && sysInfo.m_dwMajor >= 4)  {
  83. #if _MSC_VER >= 1100
  84.         ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &m_uScrollLines, 0);
  85. #endif
  86.     }
  87.     else if(hWheel)    {
  88.         m_uScrollLines = (UINT)::SendMessage(hWheel, msg_ScrollLines, 0, 0);
  89.     }
  90. }
  91.  
  92. HWND CMouseWheel::GetWheelWnd()
  93. {
  94.     HWND hRetval = NULL;
  95. #if _MSC_VER >= 1100
  96.     hRetval = ::FindWindow(MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE);
  97. #endif
  98.     return(hRetval);
  99. }
  100.  
  101. UINT CMouseWheel::ScrollLines()
  102. {
  103.     return(m_uScrollLines);
  104. }
  105.