fontcombobox.cpp

来自「《AE库通用模块及典型系统开发实例导航》光盘内容分享!」· C++ 代码 · 共 59 行

CPP
59
字号
// 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);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?