【VC开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了VC开源代码-FONTCOMBO.CPP的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
// FontBox.cpp : implementation file
//
#include "Stdafx.h"
#include "resource.h"
#include "FontCombo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// Constant and should not be changed unless
// image IDB_GLYPH is changed
#define GLYPH_WIDTH 15
//////////////////////////////////////////////////////////////////////////
// ?Paramax Technology Limited //
// ---------------------------- //
// //
// The author accepts no liablility for injury or loss of profits //
// if this software is used. You willingness to use this software //
// indicates you accept total liability //
// //
//////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CFontCombo
////////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: CACFontCombo::CFontCombo
//
// DESCRIPTION: Constructor
//
// INPUTS:
//
// RETURNS:
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// N T ALMOND 25/09/98 1.0 Origin
//
////////////////////////////////////////////////////////////////////////////////
CFontCombo::CFontCombo()
{
// Load up glyphs
m_img.Create(IDB_GLYPHS,15,1,RGB(255,0,255));
}
////////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: CFontCombo::~CFontCombo
//
// DESCRIPTION: Constructor
//
// INPUTS:
//
// RETURNS:
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// N T ALMOND 25/09/98 1.0 Origin
//
////////////////////////////////////////////////////////////////////////////////
CFontCombo::~CFontCombo()
{
}
BEGIN_MESSAGE_MAP(CFontCombo, CComboBox)
//{{AFX_MSG_MAP(CFontCombo)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_CONTROL_REFLECT(CBN_KILLFOCUS, OnKillfocus)
ON_CONTROL_REFLECT(CBN_SETFOCUS, OnSetfocus)
ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseUp)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFontCombo message handlers
// Overridables for onwerdraw combos
void CFontCombo::DeleteItem(LPDELETEITEMSTRUCT)
{
}
// Overridables for onwerdraw combos
void CFontCombo::MeasureItem(LPMEASUREITEMSTRUCT)
{
}
// Initialize fonts for combo
int CFontCombo::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CComboBox::OnCreate(lpCreateStruct) == -1)
return -1;
Initialize();
return 0;
}
////////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: CFontCombo::DrawItem
//
// DESCRIPTION: Owner draw to render bitmap and font name
//
// INPUTS:
//
// RETURNS:
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// N T ALMOND 25/09/98 1.0 Origin
//
////////////////////////////////////////////////////////////////////////////////
void CFontCombo::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
ASSERT(lpDIS->CtlType == ODT_COMBOBOX); // We've gotta be a combo
// Lets make a CDC for ease of use
CDC *pDC = CDC::FromHandle(lpDIS->hDC);
ASSERT(pDC); // Attached failed
CRect rc(lpDIS->rcItem);
// Draw focus rectangle
if (lpDIS->itemState & ODS_FOCUS)
pDC->DrawFocusRect(rc);
// Save off context attributes
int nIndexDC = pDC->SaveDC();
CBrush brushFill;
// Draw selection state
if (lpDIS->itemState & ODS_SELECTED)
{
brushFill.CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT