VC++实现工具栏上添加平面组合框控件(3)
///////////////////////////////// CFlatComboBox
CFlatComboBox::CFlatComboBox()
{
m_bLBtnDown = false;
}
CFlatComboBox::~CFlatComboBox()
{}
BEGIN_MESSAGE_MAP(CFlatComboBox, CComboBox)
//{{AFX_MSG_MAP(CFlatComboBox)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_TIMER()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
///////////////////////////////////////////////////// CFlatComboBox message handlers
void CFlatComboBox::OnMouseMove(UINT nFlags, CPoint point)
{
SetTimer(1,10,NULL);
CComboBox::OnMouseMove(nFlags, point);
}
void CFlatComboBox::OnLButtonDown(UINT nFlags, CPoint point)
{
m_bLBtnDown = true;
CComboBox::OnLButtonDown(nFlags, point);
}
void CFlatComboBox::OnLButtonUp(UINT nFlags, CPoint point)
{
m_bLBtnDown = false;
Invalidate();
CComboBox::OnLButtonUp(nFlags, point);
}
void CFlatComboBox::OnTimer(UINT nIDEvent)
{
POINT pt;
GetCursorPos(&pt);
CRect rcItem;
GetWindowRect(&rcItem);
static bool bPainted = false;
// OnLButtonDown, show pressed.
if (m_bLBtnDown==true) {
KillTimer (1);
if (bPainted == true) {
DrawCombo(FC_DRAWPRESSD, ::GetSysColor(COLOR_BTNSHADOW),::GetSysColor(COLOR_BTNHIGHLIGHT));
bPainted = false;
}
return;
}