Click here to Skip to main content
11,495,371 members (66,484 online)
Click here to Skip to main content

The Ultimate Toolbox Intellimouse Classes

, 25 Aug 2007 CPOL 17.6K 22 10
Rate this:
Please Sign up or sign in to vote.
The Ultimate Toolbox Intellimouse classes make it easy to add advanced scrolling capabilities to your application.

Visit the Ultimate Toolbox main page for an overview and configuration guide to the Ultimate Toolbox library.

Contents

Introduction

You can customize any window in you application to support IntelliMouse functionality with the Ultimate Toolbox IntelliMouse classes.


The Intellimouse sample can be found in the samples\gui\IntelliMouse dir of the samples download.

IntelliMouse Classes

Intellimouse support can be added to any MFC based window through the use of the COXIntelliMouse and COXIntelliMouseOrganizer classes.

COXIntellimouse

COXIntelliMouse is derived from COXHookWnd and uses COXSplashWnd internally. Also, in order to visually display the direction of the scrolling when Intelli Mouse Support is on, COXIntelliMouse class uses a set of cursors that is defined in include\OXIntelliMouse.rc.

The following steps can be used in order to provide IntelliMouse Support in your application using the COXIntelliMouse class (defined in OXIntellimouse.h and OXIntellimouse.cpp):

  1. Instantiate one object of the COXIntelliMouse class for each window class for which you are going to provide IntelliMouse Support.
class CMyView : public CView
{
     . . . 
     protected:
     // intellimouse support

     COXIntelliMouse m_IntelliMouse;
     . . . 
}
  1. In your OnCreate function call COXIntelliMouse::Attach in order to register it with the COXIntelliMouse object and to set up the start event that will be interpreted as a trigger to launch IntelliMouse Support:
int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
     . . .
     // mouse left button down altogether with "Ctrl" key pressed down

     // will launch Intelli Mouse Support

     m_IntelliMouse.Attach(this,WM_LBUTTONDOWN,KEYPRESSED_CONTROL);   
     // or KEYPRESSED_SHIFT, KEYPRESSED_ALT

     . . .  
}

The Detach function can be used in order to remove IntelliMouse Support.

The following functions can be used to specify the appearance of the splash window and cursors that show the scrolling direction:

HCURSOR GetScrollCursor(const SCROLLDIRECTION scrollDirection) const
void    SetScrollCursor(const SCROLLDIRECTION scrollDirection, 
    const HCURSOR hCursor)
BOOL    LoadSplashWndBitmap(LPCTSTR lpszResourceName, 
    const COLORREF crBorder = CLR_DEFAULT, const LPPOINT pStartPoint = NULL, 
    const BYTE nTolerance = 0)
BOOL    LoadSplashWndBitmap(const UINT nIDResource, 
    const COLORREF crBorder = CLR_DEFAULT, const LPPOINT pStartPoint = NULL, 
    const BYTE nTolerance = 0)

And, finally, there are functions that let you to request and change the settings that have to do with the way IntelliMouse Support is launched:

UINT    GetStartEventID() const
UINT    GetKeyPressedState() const
void    SetStartEventID(const UINT nStartEventID, const DWORD dwKeyState=0)

COXIntellimouseOrganizer

This class provides functionality similar to COXIntelliMouse - the difference being the added functionality for IntelliMouse support of multiple windows. It uses one COXIntelliMouse object for each specified window.

To attach a single window to a COXIntelliMouse object use the Attach function. To detach a single window call the Detach function.

To attach a main window and all of its child windows call AttachAllWindows.

COXIntelliMouse objects can also be specified for all windows belonging to a particular thread using the GetAttachedThread, IsAttachedAllInThread, AttachAllInThread, and DetachAllInThread functions.

History

Initial CodeProject release August 2007.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

The Ultimate Toolbox
Web Developer
Canada Canada
In January 2005, David Cunningham and Chris Maunder created TheUltimateToolbox.com, a new group dedicated to the continued development, support and growth of Dundas Software’s award winning line of MFC, C++ and ActiveX control products.

Ultimate Grid for MFC, Ultimate Toolbox for MFC, and Ultimate TCP/IP have been stalwarts of C++/MFC development for a decade. Thousands of developers have used these products to speed their time to market, improve the quality of their finished products, and enhance the reliability and flexibility of their software.
Group type: Organisation

404 members


Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150520.1 | Last Updated 25 Aug 2007
Article Copyright 2007 by The Ultimate Toolbox
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid