📄 font.cpp
字号:
// Font.cpp: implementation of the CFont class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "AbException.h"
#include "mixer.h"
#include "Font.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CAbFont::CAbFont()
: m_hFont(0),m_uRefs(0),nWidth(0),nHeight(0),nEscapement(0),nOrientation(0),
fnWeight(FW_DONTCARE),fdwItalic(0),fdwUnderline(0),fdwStrikeOut(0),
fdwCharSet(ANSI_CHARSET),fdwOutputPrecision(OUT_DEFAULT_PRECIS),
fdwClipPrecision(CLIP_DEFAULT_PRECIS),fdwQuality(DEFAULT_QUALITY),
fdwPitchAndFamily(DEFAULT_PITCH|FF_DONTCARE),lpszFace("Small"),m_strFont("")
{
}
void CAbFont::SetHt(int i,HDC hDC)
{
if(hDC == 0)
{
nHeight=i;
return;
}
nHeight=MulDiv(-i, GetDeviceCaps(hDC, LOGPIXELSY), 72);
// nHeight=i;
}
void CAbFont::Create()
{
if(m_strFont.length() > 0)
lpszFace=m_strFont.c_str();
m_hFont=CreateFont(nHeight,nWidth,nEscapement,nOrientation,fnWeight,
fdwItalic,fdwUnderline,fdwStrikeOut,fdwCharSet,fdwOutputPrecision,
fdwClipPrecision,fdwQuality,fdwPitchAndFamily,lpszFace);
if(!m_hFont) {
throw CAbException(::GetLastError(),__FILE__,__LINE__);
}
}
void CAbFont::Delete()
{
if(m_hFont)
DeleteObject(m_hFont);
m_hFont=0;
}
CAbFont::~CAbFont()
{
Delete();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -