fontui.h

来自「标签控制」· C头文件 代码 · 共 35 行

H
35
字号
////////////////////////////////////////////////////////////////
// MSDN Magazine -- October 2002
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual Studio 6.0 on Windows XP. Tab size=3.
//
class CFontUI {
protected:
	int		m_nFontPtSizeMin;	// min..
	int		m_nFontPtSizeMax;	// ..and max font size in points

	// Override to change grow/shrink algorithm
	virtual int GrowFontSize(int ptSize, int dir);

public:
	CFontUI();
	virtual ~CFontUI();

	// universal function for bigger/smaller/dialog
	BOOL OnChangeFont(CFont& font, int op, CWnd* pWnd=NULL, DWORD dwFlags=0);

	void SetMinMaxFontSize(int nMin, int nMax)
		{ m_nFontPtSizeMin = nMin; m_nFontPtSizeMax = nMax; }

	// Handy conversion functions
	int  GetFontPointSize(CFont& font, CDC& dc);
	BOOL SetFontPointSize(CFont& font, CDC& dc, int pts);

	// Functions to read/write font in profile (registry settings or .ini)
	BOOL WriteProfileFont(LPCTSTR lpszKey, LPCTSTR lpszVal, CFont& font,
		CDC* pDC=NULL);
	BOOL GetProfileFont(LPCTSTR lpszKey, LPCTSTR lpszVal, CFont& font,
		CDC* pDC=NULL);
};

⌨️ 快捷键说明

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