组合框.cpp
资源名称:ComBox.rar [点击查看]
上传用户:shlcjx
上传日期:2008-11-20
资源大小:21k
文件大小:1k
源码类别:
组合框控件
开发平台:
Visual C++
- // MyComboBox.cpp : implementation file
- //
- #include "stdafx.h"
- #include "组合框.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMyComboBox
- CMyComboBox::CMyComboBox()
- { m_ColorText=RGB(255,0,0);
- m_ColorBk=RGB(224,236,200);
- m_Brush.CreateSolidBrush(m_ColorBk);
- }
- CMyComboBox::~CMyComboBox()
- {
- }
- BEGIN_MESSAGE_MAP(CMyComboBox, CComboBox)
- //{{AFX_MSG_MAP(CMyComboBox)
- ON_WM_CTLCOLOR()
- ON_WM_CTLCOLOR_REFLECT()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMyComboBox message handlers
- HBRUSH CMyComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);
- pDC->SetTextColor(m_ColorText);
- pDC->SetBkColor(m_ColorBk);
- return m_Brush;
- return hbr;
- }
- HBRUSH CMyComboBox::CtlColor(CDC* pDC, UINT nCtlColor)
- {
- pDC->SetTextColor(m_ColorText);
- pDC->SetBkColor(m_ColorBk);
- return m_Brush;
- return NULL;
- }
- //设置字大小
- void CMyComboBox::SetFontSize(int iSize,CFont* font)
- {
- font->CreatePointFont(iSize,_T("Times New Roman"));
- LOGFONT lf;
- font->GetLogFont(&lf);
- font->DeleteObject();
- lf.lfWeight = FW_BOLD;
- font->CreateFontIndirect(&lf);
- SetFont(font);
- }