Solved

Using the mouse wheel

Posted on 1998-05-10
4
778 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 55
Folder Comparison 12 53
ODBC Connection Logging, ADO.NET 6 56
NotAlone Challenge 20 80
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

861 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

30 Experts available now in Live!

Get 1:1 Help Now