📄 enumfontcombobox.cpp
字号:
// EnumFontComboBox.cpp : implementation file
//
#include "stdafx.h"
//#include "unicode.h"
#include "EnumFontComboBox.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEnumFontComboBox
CEnumFontComboBox::CEnumFontComboBox()
{
}
CEnumFontComboBox::~CEnumFontComboBox()
{
}
BEGIN_MESSAGE_MAP(CEnumFontComboBox, CComboBox)
//{{AFX_MSG_MAP(CEnumFontComboBox)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEnumFontComboBox message handlers
void CEnumFontComboBox::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
ProcessEnumFonts();
CComboBox::PreSubclassWindow();
}
void CEnumFontComboBox::ProcessEnumFonts()
{
CStringList m_fontlist;
m_fontlist.RemoveAll();
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
EnumFontFamiliesEx(GetParent()->GetDC()->GetSafeHdc(), &lf, (FONTENUMPROC)EnumFontsProc, (LPARAM)&m_fontlist, 1);
ResetContent();
for (POSITION ps = m_fontlist.GetHeadPosition(); ps != NULL;){
AddString( m_fontlist.GetNext(ps) );
}
}
int CALLBACK CEnumFontComboBox::EnumFontsProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, int FontType, LPARAM lParam)
{
if ( strlen( (char *)lpelfe->elfFullName ) != 0)
{
CStringList *sl = (CStringList *) lParam;
sl->AddTail(lpelfe->elfFullName );
}
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -