28.3 The mouse wheel


Though not everyone has a wheel mouse yet, they are becoming more popular. If you don't have one, you really should get one, as the wheel makes it a lot easier to scroll through all the files you have to look at when you're programming. An additional good feature of some wheel mice (such as Microsoft's high-end one) is that you can press down on the wheel to simulate a double click.

You can add a handler for WM_MOUSEWHEEL to add a method BOOL CPopView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) . Check the Visual Studio help for the meaning of the arguments.

For our purposes, we only want the mouse wheel to scroll through the different tool types. In the Pop Framework build, the mouse wheel scrolls through all the available cursors for each game. Thanks to encapsulation and OOP, the mouse wheel code is particularly clean.

 BOOL CPopView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)  {  /* Swap the cursor functionality, depending which cursors the game      uses. We just use the sign of zdelta, which will be some positive      or negative number, depending on which way and how far you turned      the wheel. */      pgame()->nextHCURSOR(_hCursor, zDelta);      return TRUE;  } 


Software Engineering and Computer Games
Software Engineering and Computer Games
ISBN: B00406LVDU
EAN: N/A
Year: 2002
Pages: 272

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net