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

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
///////////////////////////////////////////////////////////////
//
// WindowHook.h
//
// Created: 29/07/2003
// Copyright (c) 2003 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 __WINDOWHOOK_H_06EA5989_97D5_4C6D_B78E_0FF52C84FEAF_
#define __WINDOWHOOK_H_06EA5989_97D5_4C6D_B78E_0FF52C84FEAF_

/**
 * Class to hook the window creation/destruction for the current thread.
 * Not to be used directly @see WindowHookManager
 **/
class WindowHook
{
public:
/**
 * Callback interface to notify clients of window
 * creation/destruction
 **/
    struct Observer
    {
        virtual void OnCreate( HWND hWnd ) = 0;
        virtual void OnDestroy( HWND hWnd ) = 0;
    };

/**
 * Only the hook manager is allowed to create instances of this
 * hook object
 **/
private:
    friend class WindowHookManager;

    WindowHook();
    ~WindowHook();

private:
/**
 * Callback function passed to SetWindowsHookEx @see SetWindowsHookEx
 **/
    static LRESULT CALLBACK CallWndRetProc( int nCode, WPARAM wParam, LPARAM lParam );

private:
/**
 * Member function called by CallWndRetProc. Check the hook code
 * and if appropriate inform the observer.
 **/
    LRESULT OnHook( int nCode, WPARAM wParam, LPARAM lParam );

private:
    HHOOK       m_hook;             /// < the windows hook
    Observer    *m_pObserver;       /// < the callback interface
};

/**
 * The window hook manager is a singleton object responsible
 * for managing an instance of the WindowHook object for
 * each thread that AttachHook is called on. 
 * When constructed, the singleton requests a slot of thread local
 * storage (tls). Each time AttachHook is called, the hook manager
 * retrieves the contents of the tls slot. If this is NULL, a new
 * WindowHook object is created for that thread, and a pointer to
 * that object written into the tls slot.
 * Each time the hook is triggered, the hook callback function
 * will call into this manager (hence the friend access) and retrieve
 * the hook object for that thread.
 **/

class WindowHookManager
{
    friend class WindowHook;

private:
    WindowHookManager();

public:
    ~WindowHookManager();

private:
/**
 * Retrieve the hook for the current thread. If no hook is
 * allocated then create a new one
 **/
    WindowHook * GetHook();

public:
    void AttachHook( WindowHook::Observer *pObserver );
    void ReleaseHook();

public:
    static WindowHookManager & GetInstance();

private:
    DWORD   m_tlsIndex;     /// < the tls slot index
};

#endif // __WINDOWHOOK_H_06EA5989_97D5_4C6D_B78E_0FF52C84FEAF_

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 | Mobile
Web03 | 2.8.140916.1 | Last Updated 21 Sep 2005
Article Copyright 2003 by Ralph Hare
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid