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

📄 page1font.cpp

📁 精通MFC程序设计 第9章属性表与向导
💻 CPP
字号:
// Page1Font.cpp : implementation file
//

#include "stdafx.h"
#include "Chapter09.h"
#include "Page1Font.h"
#include "MainFrm.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPage1Font property page

int WINAPI EnumFontFamProc(
  const LOGFONTA  *lpelf,		//pointer to logical-font data
  const TEXTMETRICA  *lpntm,	//pointer to physical-font data
  unsigned long FontType,       //type of font
  LPARAM lParam					//pointer to application-defined data
)
{
	CListBox* pListBox=(CListBox*)lParam;
	CString str;
	str.Format("%s+%d",lpelf->lfFaceName,lpelf->lfCharSet);
	//将可用字体及字符集添加到列表框
	pListBox->AddString(str);
	return TRUE;
}

IMPLEMENT_DYNCREATE(CPage1Font, CPropertyPage)

CPage1Font::CPage1Font() : CPropertyPage(CPage1Font::IDD)
{
	//{{AFX_DATA_INIT(CPage1Font)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CPage1Font::~CPage1Font()
{
}

void CPage1Font::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPage1Font)
	DDX_Control(pDX, IDC_FONT, m_lstFont);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPage1Font, CPropertyPage)
	//{{AFX_MSG_MAP(CPage1Font)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPage1Font message handlers

BOOL CPage1Font::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	//创建新的字体
	CFont font;
	font.CreatePointFont(120,"楷体_GB2312");
	//设置列表框中的字体
	m_lstFont.SetFont(&font);
	m_lstFont.SetTabStops(220);
	//枚举系统可用字体
	EnumFontFamilies(::GetDC(GetSafeHwnd()),NULL,EnumFontFamProc,(LPARAM)(&m_lstFont));
	//默认字体
	m_lstFont.SetCurSel(0);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

BOOL CPage1Font::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	SetModified(TRUE);
	return CPropertyPage::OnCommand(wParam, lParam);
}

BOOL CPage1Font::OnApply() 
{
	// TODO: Add your specialized code here and/or call the base class
	CMainFrame* pMFrm=(CMainFrame*)AfxGetMainWnd();
	//向视图类发送用户自定义消息
	pMFrm->GetActiveView()->SendMessage(WM_USER_APPLY);
	return TRUE;
}

⌨️ 快捷键说明

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