📄 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);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -