百分求助:请高手帮忙解读代码!
最近读到一段源代码,没看明白,请高手帮忙指点下!
#if !defined(AFX_TRACKCONTROL_H__06A38C29_E713_4289_97B5_EC17CA3DAED0__INCLUDED_)
#define AFX_TRACKCONTROL_H__06A38C29_E713_4289_97B5_EC17CA3DAED0__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// TrackControl.h : header file
// Modified by jingzhou xu
template<class BaseClass>
/////////////////////////////////////////////////////////////////////////////
// CTrackControl window
class CTrackControl : public BaseClass
{
// Construction
public:
CTrackControl()
{
m_bTracking=m_bHover=FALSE;
}
virtual ~CTrackControl() {}
BOOLEAN IsHover()
{
return m_bHover;
}
// Implementation
public:
virtual void OnHoverEnter()=0;
virtual void OnHoverLeave()=0;
// Generated message map functions
protected:
virtual LRESULT WindowProc(UINT nMessage, WPARAM wParam, LPARAM lParam)
{
LRESULT nResult=BaseClass::WindowProc(nMessage,wParam,lParam);
switch(nMessage)
{
case WM_MOUSEMOVE:
{
if (!m_bTracking)
{
TRACKMOUSEEVENT Tme;
Tme.cbSize = sizeof(Tme);
Tme.hwndTrack = GetSafeHwnd();
Tme.dwFlags = TME_LEAVE|TME_HOVER;
Tme.dwHoverTime = 1;
if (_TrackMouseEvent(&Tme))
m_bTracking=TRUE;
}
break;
}
case WM_MOUSEHOVER:
m_bHover=TRUE;
OnHoverEnter();
break;
case WM_MOUSELEAVE:
m_bTracking=m_bHover=FALSE;
OnHoverLeave();
break;
}
return nResult;
}
private:
BOOLEAN m_bTracking;
BOOLEAN m_bHover;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TRACKCONTROL_H__06A38C29_E713_4289_97B5_EC17CA3DAED0__INCLUDED_)