Click here to Skip to main content
15,897,891 members
Articles / Web Development / HTML

Mouse Gestures for Internet Explorer

Rate me:
Please Sign up or sign in to vote.
4.84/5 (99 votes)
21 Sep 200514 min read 1.3M   13.4K   235  
Adding mouse gesture recognition to Internet Explorer.
///////////////////////////////////////////////////////////////
//
// HotKeyCtrlEx.h
//
// Created: rhare - 21/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.
//
///////////////////////////////////////////////////////////////

#ifndef __HOTKEYCTRLEX_H_EC56A64E_0A51_4304_B13C_260CFE817DED_
#define __HOTKEYCTRLEX_H_EC56A64E_0A51_4304_B13C_260CFE817DED_

#include "KeyboardHook.h"

/**
 * HotKeyCtrlEx provides the same functionality as CHotKeyCtrl
 * (which is a wrapper around a msctls_hotkey32 window). CHotKeyCtrl
 * suffers from one major deficiency - its unable to capture
 * any keystrokes that include the TAB key. 
 *
 * HotKeyCtrlEx corrects this deficiency by extending the functionality
 * of an EDIT window. It achieves this by installing a low-level keyboard
 * hook to capture all keystrokes. If the keystroke is originated
 * while the EDIT window has focus, HotKeyCtrlEx will filter
 * messages such as Ctrl-Tab & Alt-Tab - The Tab key on its own and
 * Shift-Tab are currently un-filtered.
 *
 * Note: Subclassing the window isn't sufficient. When the hot-key
 * control is part of a property page, the property sheet window
 * always processes the Ctrl-Tab message before it gets to the
 * hot-key window.
 **/
class HotKeyCtrlEx : private KeyboardHook::Observer
{
public:
    HotKeyCtrlEx();
    ~HotKeyCtrlEx();

    HotKeyCtrlEx & operator = ( HWND hWnd );

    void GetHotKey( WORD &wVirtKeyCode, WORD &wModifiers );
    void SetHotKey( WORD wVirtKeyCode, WORD wModifiers );

private:
    LRESULT OnKeyDown( const KBDLLHOOKSTRUCT *pks );
    LRESULT OnKeyUp( const KBDLLHOOKSTRUCT *pks );

private:
    LRESULT OnKeyHook( UINT uMsg, const KBDLLHOOKSTRUCT *pks );

private:
    HWND    m_hWnd;

    WORD    m_vkCode;
    WORD    m_modifiers;

    WORD    m_activeModifiers;

    KeyboardHook    m_keyHook;
};

#endif // __HOTKEYCTRLEX_H_EC56A64E_0A51_4304_B13C_260CFE817DED_

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


Written By
Web Developer
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions