EnumFontComboBox.cpp
资源名称:fontcurve.rar [点击查看]
上传用户:sz81710966
上传日期:2013-03-01
资源大小:409k
文件大小:2k
源码类别:
多国语言处理
开发平台:
Visual C++
- // 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;
- }