Solved

Using the mouse wheel

Posted on 1998-05-10
4
789 Views
Last Modified: 2013-11-20
I would like to use the mouse wheel in an Windows 95 application. I'm unable to intercept the WM_MOUSEWHEEL message (because it's unsupported under Windows 95). How can I do?
0
Comment
Question by:bonduel
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:Blondie050798
ID: 1309277
You have to use OnRegisteredMouseWheel()
0
 

Author Comment

by:bonduel
ID: 1309278
I know that, but what is the way to use OnRegisteredMouseWheel (there is no message WM_REGISTEREDMOUSEWHEEL).
0
 
LVL 1

Accepted Solution

by:
Blondie050798 earned 200 total points
ID: 1309279
The document does explain (although not very well!)

The framework calls this member function as a user rotates the mouse wheel and encounters the wheel's next notch. Unless overridden, OnRegisteredMouseWheel registers the Windows message, routes the message to the appropriate window, and calls the WM_MOUSEWHEEL handler for that window.

It is far easier to understand what is going on by looking at the source used by mfc, and simply 'do your own thing' as required!

So looking at the mfc source:

// register for Windows 95 or Windows NT 3.51
static UINT nMsgMouseWheel =
   (((::GetVersion() & 0x80000000) && LOBYTE(LOWORD(::GetVersion()) == 4)) ||
       (!(::GetVersion() & 0x80000000) && LOBYTE(LOWORD(::GetVersion()) == 3)))
       ? ::RegisterWindowMessage(MSH_MOUSEWHEEL) : 0;

and then in the message map:
ON_REGISTERED_MESSAGE(nMsgMouseWheel, OnRegisteredMouseWheel)

and then the actual source:
LRESULT CFrameWnd::OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam)
{
      // convert from MSH_MOUSEWHEEL to WM_MOUSEWHEEL

      WORD keyState = 0;
      keyState |= (::GetKeyState(VK_CONTROL) < 0) ? MK_CONTROL : 0;
      keyState |= (::GetKeyState(VK_SHIFT) < 0) ? MK_SHIFT : 0;

      LRESULT lResult;
      HWND hwFocus = ::GetFocus();
      const HWND hwDesktop = ::GetDesktopWindow();

      if (hwFocus == NULL)
            lResult = SendMessage(WM_MOUSEWHEEL, (wParam << 16) | keyState, lParam);
      else
      {
            do {
                  lParam = ::SendMessage(hwFocus, WM_MOUSEWHEEL,
                        (wParam << 16) | keyState, lParam);
                  hwFocus = ::GetParent(hwFocus);
            }
            while (lParam == 0 && hwFocus != NULL && hwFocus != hwDesktop);
      }
      return lResult;
}
0
 

Author Comment

by:bonduel
ID: 1309280
Thank U
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Replacement selected text 2 62
notReplace  challenge 53 131
abstract class with all non abstract mentods 6 76
Path of Workbook 3 79
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question