【VC开源代码栏目提醒】:网学会员在VC开源代码频道为大家收集整理了CJOUTLOOKBAR.CPP提供大家参考,希望对大家有所帮助!
// CJOutlookBar.cpp : implementation file
//
// Copyright ?1998 Written by Kirk Stowell
// mailto:kstowel@sprynet.com
// http://www.geocities.com/SiliconValley/Haven/8230
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed unmodified by any means PROVIDING it is
// not sold for profit without the authors written consent, and
// providing that this notice and the authors name and all copyright
// notices remains intact. If the source code in this file is used in
// any commercial application then a statement along the lines of
// "Portions Copyright ?1998 Kirk Stowell" must be included in
// the startup banner, "About" box or printed documentation. An email
// letting me know that you are using it would be nice as well. That's
// not much to ask considering the amount of work that went into this.
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability for any damage/loss of business that
// this product may cause.
//
// ==========================================================================
// HISTORY:
// ==========================================================================
// 1.00 17 Oct 1998 - Initial re-write and release.
// ==========================================================================
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CJOutlookBar.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCJOutlookBar
CCJOutlookBar::CCJOutlookBar()
{
m_bLBDown = false;
m_bHilight = true;
}
CCJOutlookBar::~CCJOutlookBar()
{
// TODO: add destruction code here.
}
IMPLEMENT_DYNAMIC(CCJOutlookBar, CListBox)
BEGIN_MESSAGE_MAP(CCJOutlookBar, CListBox)
//{{AFX_MSG_MAP(CCJOutlookBar)
ON_WM_ERASEBKGND()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCJOutlookBar message handlers
// Checks mouse movement, sets point member, sets timer.
void CCJOutlookBar::OnMouseMove(UINT nFlags, CPoint point)
{
m_point = point;
SetTimer (1, 10, NULL);
CListBox::OnMouseMove(nFlags, point);
}
// Sets bLBDown member to true, and sets current selection
void CCJOutlookBar::OnLButtonDown(UINT nFlags, CPoint point)
{
m_bLBDown = true;
SetCurSel(GetCurSel());
CListBox::OnLButtonDown(nFlags, point);
}
// Sets bLBDown member to false, and sets current selection
void CCJOutlookBar::OnLButtonUp(UINT nFlags, CPoint point)
{
m_bLBDown = false;
SetCurSel(GetCurSel());
p_Owner->SendMessage(WM_OUTLOOKBAR_NOTIFY,
OBM_ITEMCLICK, GetCurSel());
CListBox::OnLButtonUp(nFlags, point);
}
// Sets the hilite flag based on cursor position.
void CCJOutlookBar::OnTimer(UINT nIDEvent)
{
BOOL bOutSide;
CRect rItem;
CRect rWindow;
CPoint pt;
int nIndex;
// Get the rect of the current window,
// get the current cursor position.
GetWindowRect (rWindow);
GetCursorPos (&pt);
// If the mouse is in the rect of this window,
// set hilite flag to true, get the item that
// the mouse is over.
if (rWindow.PtInRect (pt)) {
m_bHilight = true;
nIndex = ItemFromPoint (m_point, bOutSide);
if (nIndex != GetCurSel() && !bOutSide) {
SetCurSel( nIndex );
}
}
// If the mouse is not in the rect of
// this window, kill the timer, set hilite flag
// to false, and return.
else {
m_bHilight = false;
if( !m_bLBDown ) {
SetCurSel (-1);
}
KillTimer(1);
}
}
/