【VC开源代码栏目提醒】:以下是网学会员为您推荐的VC开源代码-FontComboBox.cpp,希望本篇文章对您学习有所帮助。
// FontComboBox.cpp : implementation file
//
#include "stdafx.h"
#include "MyRichEdit.h"
#include "FontComboBox.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFontComboBox
CFontComboBox::CFontComboBox()
{
}
CFontComboBox::~CFontComboBox()
{
}
BEGIN_MESSAGE_MAP(CFontComboBox, CComboBox)
//{{AFX_MSG_MAP(CFontComboBox)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFontComboBox message handlers
//回调函数
int CALLBACK numEnumFontNameProc(LOGFONT *plf, TEXTMETRIC* lpntme, int FontType, LPARAM lParam)
{
//将字体添加到字体下拉框中
CFontComboBox * fcb = (CFontComboBox *) lParam;
fcb->AddString(plf->lfFaceName);
return 1;
}
void CFontComboBox::AddFont(CDC *pDC)
{
Clear();
if (!pDC)
{
pDC = GetDC();
}
LOGFONT lf;
lf.lfFaceName[0] = 0;
lf.lfCharSet = DEFAULT_CHARSET;
//枚举系统字体
EnumFontFamilies(pDC->m_hDC, NULL, (FONTENUMPROC)numEnumFontNameProc, (LPARAM)this);
if (GetCount() > 0)
SetCurSel(0);
}
上一篇:
FONTCOMBO.CPP
下一篇:
三年级起点六年级上册英语全册教案(新标准英语)