// ExComboBox.cpp : implementation file
//
#include "stdafx.h"
#include "ExComboBox.h"
// CExComboBox
#define EXCOMBOBOX_OFFSET (1)
#define COLOR_BK_COMBOBOX_DISABLE RGB(223,228,232)
#define COLOR_BORDER_COMBOBOX_DISABLE RGB(160,176,191)
IMPLEMENT_DYNAMIC(CExComboBox, CComboBox)
CExComboBox::CExComboBox()
{
}
CExComboBox::~CExComboBox()
{
}
BEGIN_MESSAGE_MAP(CExComboBox, CComboBox)
ON_WM_PAINT()
END_MESSAGE_MAP()
// CExComboBox message handlers
void CExComboBox::OnPaint()
{
if(IsWindowEnabled())
{
Default();
}
else
{
CPaintDC dc(this); // device context for painting
CRect rect;
CRect rcText;
borderboxGetClientRect(rect);
/* rcText = rect;
rect.left = rect.right - ::GetSystemMetrics(SM_CXHSCROLL);
rcText.right = rect.left-1;
GetClientRect(rect)*/;
// COLORREF clrDisabledBkg = ::GetSysColor(COLOR_BTNFACE);
COLORREF clrDisabledBkg = COLOR_BK_COMBOBOX_DISABLE;
// COLORREF clrDisabledBorder = ::GetSysColor(COLOR_3DDKSHADOW);
COLORREF clrDisabledBorder = COLOR_BORDER_COMBOBOX_DISABLE;
COLORREF clrDisabledText = ::GetSysColor(COLOR_GRAYTEXT);
CBrush brDisabled(clrDisabledBkg);
CBrush* pOldBrush = dc.SelectObject(&brDisabled);
CPen penDisabled( PS_SOLID, 0, clrDisabledBorder);
CPen* pOldPen = dc.SelectObject(&penDisabled);
dc.Rectangle(rect);
// COLORREF clrTopLeft = ::GetSysColor(COLOR_3DSHADOW);
// COLORREF clrBottomRight = ::GetSysColor(COLOR_3DHILIGHT);
// dc.Draw3dRect( &rect, clrTopLeft, clrBottomRight );
// clrTopLeft = ::GetSysColor(COLOR_3DDKSHADOW);
// clrBottomRight = ::GetSysColor(COLOR_3DLIGHT);
// rect.DeflateRect(3,1);
// dc.Draw3dRect( &rect, clrTopLeft, clrBottomRight );
CRect rcDropButton(rect);
rcDropButton.left = rcDropButton.right - ::GetSystemMetrics(SM_CYHSCROLL);
rcDropButton.DeflateRect(-EXCOMBOBOX_OFFSET,EXCOMBOBOX_OFFSET,EXCOMBOBOX_OFFSET,EXCOMBOBOX_OFFSET);
// m_rcDropButton.left -= 1;
// m_rcDropButton.right -= 1;
// Button
DWORD dwBtnStyle = 0;
dwBtnStyle |= DFCS_INACTIVE;
dwBtnStyle |= (DFCS_SCROLLDOWN|DFCS_PUSHED|DFCS_FLAT);
dc.DrawFrameControl(rcDropButton, DFC_SCROLL, dwBtnStyle );
dc.SelectObject(pOldBrush);
dc.SelectObject(pOldPen);
rect.DeflateRect(3*EXCOMBOBOX_OFFSET,EXCOMBOBOX_OFFSET);
CString str;
GetWindowText(str);
int nOldBkMode = dc.SetBkMode(TRANSPARENT);
CFont* font = GetFont();
CFont* pOldFont = dc.SelectObject(font);
COLORREF clrOld = dc.SetTextColor(clrDisabledText);
rect.right = rcDropButton.left-1;
dc.DrawText(str, &rect, DT_SINGLELINE|DT_VCENTER);
dc.SetTextColor(clrOld);
dc.SelectObject(pOldFont);
dc.SetBkMode(nOldBkMode);
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论