Solved

Using the mouse wheel

Posted on 1998-05-10
4
764 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
Comment Utility
You have to use OnRegisteredMouseWheel()
0
 

Author Comment

by:bonduel
Comment Utility
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
Comment Utility
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
Comment Utility
Thank U
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
paragon account problem 9 96
mixString challenge 36 98
if loop in java 3 114
Modbus - whats the maximum I can store in one register? 4 74
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now