How to enable intelli mouse support when using the grid in a dialog under Windows 95 or Windows NT 3.51

If you are using the grid in a dialog under Win95 or WinNT 3.51 you have to override OnRegisteredMouseWheel and do a SendMessage to the active window. This is because Windows 95 and Windows NT 3.51 have no built-in support for the new WM_MOUSEWHEEL message.

Example:

class CAboutDlg : public CDialog
{
public:
   CAboutDlg();
   enum { IDD = IDD_ABOUTBOX };
#ifndef _MAC
   afx_msg LRESULT OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam);
#endif
   DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
// register for Windows 95 or Windows NT 3.51
#ifndef _MAC
static UINT nMsgMouseWheel =
   (((::GetVersion() & 0x80000000) && LOBYTE(LOWORD(::GetVersion()) == 4)) ||
    (!(::GetVersion() & 0x80000000) && LOBYTE(LOWORD(::GetVersion()) == 3)))
    ? ::RegisterWindowMessage(MSH_MOUSEWHEEL) : 0;
#endif
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
   //{{AFX_MSG_MAP(CAboutDlg)
   //}}AFX_MSG_MAP
#ifndef _MAC
   ON_REGISTERED_MESSAGE(nMsgMouseWheel, OnRegisteredMouseWheel)
#endif
END_MESSAGE_MAP()
#ifndef _MAC
LRESULT CAboutDlg::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;
}
#endif