Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Mouse Gestures for Internet Explorer

, 21 Sep 2005
Adding mouse gesture recognition to Internet Explorer.
mousegestures_inst.zip
MouseGestures.exe
mousegestures_inst_1.zip
MouseGestures.exe
mousegestures_src.zip
src
gesture.weights
images
about.bmp
ClickLeftRight.bmp
ClickRightLeft.bmp
down.bmp
downarrow.bmp
downleft.bmp
downright.bmp
downup.bmp
exclamation.bmp
left.bmp
leftarrow.bmp
leftright.bmp
none.bmp
right.bmp
rightarrow.bmp
rightleft.bmp
up.bmp
uparrow.bmp
updown.bmp
upleft.bmp
upright.bmp
wheel.bmp
MouseGestures.rgs
mousegestures_src_1.zip
MouseGestures
BrowserHelperObject.rgs
gesture.weights
images
about.bmp
ClickLeftRight.bmp
ClickRightLeft.bmp
down.bmp
downleft.bmp
downright.bmp
downup.bmp
left.bmp
none.bmp
right.bmp
up.bmp
updown.bmp
upleft.bmp
upright.bmp
wheel.bmp
MouseGestures.def
MouseGestures.dsp
MouseGesturesCfg.rgs
///////////////////////////////////////////////////////////////
//
// TrailWindow.h
//
// Created: 28/06/2005
// Copyright (c) 2005 Ralph Hare (ralph.hare@ysgyfarnog.co.uk)
// All rights reserved.
//
// The code and information is provided "as-is" without
// warranty of any kind, either expressed or implied.
//
///////////////////////////////////////////////////////////////

#ifndef __TRAILWINDOW_H_4AC74882_21E3_469D_A937_32CAD7268D0C_
#define __TRAILWINDOW_H_4AC74882_21E3_469D_A937_32CAD7268D0C_

#include "MouseTrail.h"
#include "CriticalSection.h"
#include <atlmisc.h>

/**
 * @brief Concrete implementation of the MouseTrail interface
 *
 * The TrailWindow creates a transparent window that covers the whole
 * screen. When the user performs a mouse gesture, the gesture path
 * is fed to TrailWindow and drawn over the active window(s).
 *
 * The mouse trail is drawn to a memory DC before being blitted to
 * the windows DC.
 **/
class TrailWindow : 
    public CWindowImpl< TrailWindow >,
    public MouseTrail
{
public:
    TrailWindow( COLORREF clr, long thickness, BYTE transparency, long fadeSpeed );
    ~TrailWindow();

BEGIN_MSG_MAP( ToolTip )
    MESSAGE_HANDLER( WM_DISPLAYCHANGE, OnDisplayChange )
    MESSAGE_HANDLER( WM_TIMER, OnTimer )
END_MSG_MAP()

public:
    static CWndClassInfo & GetWndClassInfo();

    void UpdateSettings( COLORREF clr, long thickness, BYTE transparency, long fadeSpeed );

private:
    LRESULT OnDisplayChange( UINT, WPARAM, LPARAM, BOOL & );
    LRESULT OnTimer( UINT, WPARAM, LPARAM, BOOL & );
    
// MouseTrail
private:
    virtual void Begin( HWND hWnd );
    virtual void End();
    virtual void Update( const Path &path );
    virtual void Show();
    virtual void Hide();

private:
    void SetTransparency( BYTE transparency );
    void DrawTrail( HDC hDC );
    void UpdateBitmap();

private:
    WTL::CSize              m_offset;           /// < the co-ordinates of the top-left of the window
                                                ///   that the path is relative to
    WTL::CPoint             m_lastPoint;        /// < the last point on the path we drew
    std::vector< POINT >    m_path;             /// < the adjusted path

    WTL::CDC        m_memDC;                    /// < the memory DC
    WTL::CBitmap    m_bitmap;                   /// < a bitmap compatible with the current DC, large
                                                ///   enough to cover the entire screen
    WTL::CPen       m_pen;                      /// < the pen to draw the trail
    WTL::CPen       m_penEnd;                   /// < a pen for drawing the end marker
    WTL::CBrush     m_brush;                    /// < a brush to draw the beginning & end markers
    WTL::CRect      m_rcWnd;                    /// < the size of the TrailWindow
    WTL::CRect      m_rcExtents;                /// < the bounding rect for the path

    long    m_penWidth;
    BYTE    m_transparency;
    int     m_fadeIncrement;                    /// < the increment in transparency to be used
                                                ///   when fading the window. The bigger the number,
                                                ///   the faster the fade
    double  m_sensitivity;                      /// < the number of pixels the mouse has to move
                                                ///   before the path is updated

    CriticalSection     m_csShow;
};

#endif // __TRAILWINDOW_H_4AC74882_21E3_469D_A937_32CAD7268D0C_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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

Share

About the Author

Ralph Hare
Web Developer
United Kingdom United Kingdom
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141030.1 | Last Updated 21 Sep 2005
Article Copyright 2003 by Ralph Hare
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid