Click here to Skip to main content
15,886,046 members
Articles / Desktop Programming / MFC

ImageStone - A Powerful C++ Class Library for Image Manipulation

Rate me:
Please Sign up or sign in to vote.
4.81/5 (250 votes)
6 Dec 2011Zlib3 min read 117.8K   51.5K   405  
An article on a library for image manipulation
/*
    Copyright (C) =USTC= Fu Li

    Author   :  Fu Li
    Create   :  2005-3-11
    Home     :  http://www.phoxo.com
    Mail     :  crazybitwps@hotmail.com

    This file is part of UIStone

    The code distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    Redistribution and use the source code, with or without modification,
    must retain the above copyright.
*/
#pragma once

//-------------------------------------------------------------------------------------
/**
    Monitor mouse enter/leave window.
*/
class FCTrackMouseHover
{
    BOOL   m_track ;
public:
    FCTrackMouseHover() : m_track(FALSE) {}
    virtual ~FCTrackMouseHover() {}

    /// Is mouse pointer is staying on window now.
    BOOL IsMouseHovering() const {return m_track;}

    /// @name Mouse enter/leave window event.
    //@{
    /// Event mouse enter window, default do nothing.
    virtual void OnMouse_EnterWnd() {}
    /// Event mouse leave window, default do nothing.
    virtual void OnMouse_LeaveWnd() {}
    //@}

    /// Derived class must call this function to monitor mouse event.
    void FilterMouseMessage (HWND hWnd, UINT msg)
    {
        if (msg == WM_MOUSEMOVE)
        {
            if (!m_track && ::IsWindow(hWnd))
            {
                TRACKMOUSEEVENT   t = {0} ;
                t.cbSize = sizeof(t) ;
                t.hwndTrack = hWnd ;
                t.dwFlags = TME_LEAVE ;
                m_track = TrackMouseEvent(&t) ;
                OnMouse_EnterWnd() ;
                ::InvalidateRect (hWnd, NULL, TRUE) ;
            }
        }
        else if (msg == WM_MOUSELEAVE)
        {
            if (m_track && ::IsWindow(hWnd))
            {
                // it's unnecessary to override OnKillFocus,
                // because we can receive WM_MOUSELEAVE when the window deactive.
                m_track = FALSE ;
                OnMouse_LeaveWnd() ;
                ::InvalidateRect (hWnd, NULL, TRUE) ;
            }
        }
    }
};

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, along with any associated source code and files, is licensed under The zlib/libpng License


Written By
Team Leader PhoXo
China China
graduate from University of Science and Technology of China at 2002.

Now I work at www.phoxo.com.

Comments and Discussions