This month's tip comes from Ben Dymott (bdymott@dircon.co.uk) who will get a free copy of MFC Black Book for his troubles. Thanks Ben!
If your view derives from CScrollView, MFC automatically handles the mouse wheel that appears on newer mice. But what about not CScrollViews? Ben's answer is suprisingly simple:
1) Use Class Wizard to add a OnMouseWheel handler to your view.
2) Include the following code in the skeletal handler that Class Wizard writes (using your class and base class instead of: CMyEditView and CEditView).
BOOL CMyEditView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
if (zDelta<0)
SendMessage(WM_VSCROLL,SB_LINEDOWN);
else
SendMessage(WM_VSCROLL,SB_LINEUP);
return CEditView::OnMouseWheel(nFlags,zDelta,pt);
}
Thanks Ben for this useful tip.