Click here to Skip to main content
12,826,151 members (27,714 online)
Click here to Skip to main content
Add your own
alternative version


1 download
26 bookmarked
Posted 15 Dec 1999

Getting messages from the IntelliMouse

, 15 Dec 1999
Rate this:
Please Sign up or sign in to vote.
How to set up message handlers for a wheel mouse
<!-- Article Starts -->

The IntelliMouse (the mouse with the wheel in the center) is pretty neat. You can register to get the wheel messages from it in your top level frame. If you want to handle the message in a view you must pass the message down manually as is illustrated. To get messages from the wheel add the following to your application:

  1. To make the wheel act like a simple middle button just add handlers for:


    and so-on just like left and right buttons. You won't find this in the class wizzard but you can add them manually.

  3. For wheel messages do the following:

    Declare a global in your app as follows:


    and everyplace else declare an external so you can get at it

  5. In your initialization code register the following message

    uMSH_MOUSEWHEEL = RegisterWindowMessage("MSWHEEL_ROLLMSG");
  7. (In the MAIN FRAME add the following:

    To the message map in the .H file add

    afx_msg LONG OnWheel(UINT a, LONG b);

    To the message map in the .CPP file add


    And then add the message handler as follows

    LONG CMainFrame::OnMouseWheel(UINT nFlags, LONG pValue) 
    	if(nFlags & 0x0100) // Rolled in
    		// do rolled in stuff here
    	else // Rolled out
    		// do rolled out stuff here
    	return 0;
  9. if you want to receive this message in a view then add the same handlers shown above to your view and then do the following in your main frame.

    LONG CMainFrame::OnWheel(UINT a, LONG b)
    	BOOL yn;
    	MDIChildWnd* aw = (MDIChildWnd*)MDIGetActive(&yn); 
    		CView * junk;
    		junk = aw->GetActiveView();
    	return> 0;


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Randy More
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

Generalback/forward buttons Pin
pakosan28-Apr-04 19:37
memberpakosan28-Apr-04 19:37 
GeneralRe: back/forward buttons Pin
NerdBoy13-Sep-04 11:00
memberNerdBoy13-Sep-04 11:00 
GeneralRe: back/forward buttons Pin
Franc Morales13-Sep-04 18:54
memberFranc Morales13-Sep-04 18:54 
Anonymous2-Jul-01 14:50
memberAnonymous2-Jul-01 14:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170326.1 | Last Updated 16 Dec 1999
Article Copyright 1999 by Randy More
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid