Click here to Skip to main content
12,250,675 members (49,306 online)
Click here to Skip to main content

Stats

889.1K views
12.9K downloads
233 bookmarked
Posted

Mouse Gestures for Internet Explorer

, 21 Sep 2005
Adding mouse gesture recognition to Internet Explorer.
MouseGestures.exe
MouseGestures.exe
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
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
///////////////////////////////////////////////////////////////
//
// GDIUtils.cpp
//
// Created: 09/07/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.
//
///////////////////////////////////////////////////////////////

#include "StdAfx.h"
#include "GDIUtils.h"
#include "OSUtils.h"

namespace
{
//
// Wrapper around the SetLayeredWindowAttributes API. Rather than statically
// linking to it, we dynamically link so that MouseGestures.dll will load
// on NT4 and the like, but the mouse trails will be disabled
//
    class LayerHelper
    {
    public:
        LayerHelper() :
            m_hMod( ::LoadLibrary( _T( "User32.dll" ) ) ),
            m_pfn( NULL )
        {
            m_pfn = reinterpret_cast< SLWA_PROC * >( ::GetProcAddress( m_hMod, "SetLayeredWindowAttributes" ) );
        }

        ~LayerHelper()
        {
            ::FreeLibrary( m_hMod );
        }

        BOOL __stdcall SetLayeredWindowAttribute( HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags )
        {
            if( m_pfn )
            {
                return ( *m_pfn )( hWnd, crKey, bAlpha, dwFlags );
            }

            return FALSE;
        }

    private:
        typedef BOOL ( __stdcall SLWA_PROC )( HWND, COLORREF, BYTE, DWORD );

    private:
        HMODULE     m_hMod;
        SLWA_PROC   *m_pfn;
    };
}

namespace GDIUtils
{
    BOOL __stdcall SetLayeredWindowAttribute( HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags )
    {
        if( OSUtils::IsNT4() )
        {
            return TRUE;
        }

        static LayerHelper  lh;
        return lh.SetLayeredWindowAttribute( hWnd, crKey, bAlpha, dwFlags );
    }
}

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

You may also be interested in...

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