⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wizfontnamescombobox.cpp

📁 visual c++ 实例编程
💻 CPP
字号:
// WizFontNamesComboBox.cpp : implementation file
//

#include "stdafx.h"
#include "fontsTest.h"
#include "WizFontNamesComboBox.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CWizFontNamesComboBox

CWizFontNamesComboBox::CWizFontNamesComboBox()
{
}

CWizFontNamesComboBox::~CWizFontNamesComboBox()
{
}


BEGIN_MESSAGE_MAP(CWizFontNamesComboBox, CComboBox)
	//{{AFX_MSG_MAP(CWizFontNamesComboBox)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWizFontNamesComboBox message handlers
void CWizFontNamesComboBox::Initialize(const CWizFontsEnumerator& fonts)
{
	ResetContent();
	for (int i = 0; i < fonts.GetFontsCount(); i++)
		{
		const CWizFontsEnumerator::Font* pFont = fonts.GetFont(i);
		if (pFont)
			{
			CString name = pFont->Name();
			if (pFont->IsTrueType())
				name += _T("(TT)");

			int j = AddString(name);
			if (j >= 0)
				{
				SetItemData(j, i);
				}
			else
				{
				ASSERT(0);
				}
			}
		else
			{ ASSERT(0); }
		}
	if (fonts.GetFontsCount() > 0)
		SetCurSel(0);
}

BOOL CWizFontNamesComboBox::PreCreateWindow(CREATESTRUCT& cs) 
{
	return CComboBox::PreCreateWindow(cs);
}

const CWizFontsEnumerator::Font* CWizFontNamesComboBox::GetCurrentFont(const CWizFontsEnumerator& fonts)
{
	int i = GetCurSel();
	if (i >= 0)
	{
		int j = GetItemData(i);
		if (j >= 0)
		{
			const CWizFontsEnumerator::Font* font = fonts.GetFont(j);
			ASSERT(font);
			return font;
		}
		else
		{	ASSERT(0);	}
	}
	else
	{	ASSERT(0); }

	return NULL;
}

⌨️ 快捷键说明

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