正在加载图片...
要想成为 Windows编程高手,最终一定要绕过各种封装,理解 Windows对象。但作为 个初学者,我们必须挑选一个好的封装。下面我们举字体(Font)作为例子,将三者:没 有封装过的 Windows字体API、封装过的MFC字体对象、封装过的VCL字体对象。做一个 对比。为了保证不会有偏倚和差错,有关前二者的代码,都是笔者从MSDN(微软提供的帮 助文档)中直接拷贝出来。 Windows APl创建指定样式字体 HFONT CreateFont( int nHeight,// height of font int nWidth, / average character width int eScapement, / angle of escapement t oRientation, / base-line orientation angle int fnWeight, / font weight DWORD fdwItalic, / italic attribute optio Window Pl DWORD fdwUnderline, / underline attribute option DWORD fdwStrikeOut, / strikeout attribute option DWORD fdwCharSet, / character set identifier DWORD fdwOutput Precision, / output precision DWORD fdwClipPrecision, / clipping precision WORD fdwQuality,∥/ output quallty DWORD fdwPitchAndFamily, / pitch and family LPCTSTR lpszFace / typeface name HFONT封装为 CFont BOOL CFont:: CreateFont int nHeight IFC Visual C++ int nWidth int eScapement int oRientation要想成为 Windows 编程高手,最终一定要绕过各种封装,理解 Windows 对象。但作为一 个初学者,我们必须挑选一个好的封装。下面我们举字体(Font)作为例子,将三者:没 有封装过的 Windows 字体 API、封装过的 MFC 字体对象、封装过的 VCL 字体对象。做一个 对比。为了保证不会有偏倚和差错,有关前二者的代码,都是笔者从 MSDN(微软提供的帮 助文档)中直接拷贝出来。 Window API Windows API 创建指定样式字体: HFONT CreateFont( int nHeight, // height of font int nWidth, // average character width int nEscapement, // angle of escapement int nOrientation, // base-line orientation angle int fnWeight, // font weight DWORD fdwItalic, // italic attribute option DWORD fdwUnderline, // underline attribute option DWORD fdwStrikeOut, // strikeout attribute option DWORD fdwCharSet, // character set identifier DWORD fdwOutputPrecision, // output precision DWORD fdwClipPrecision, // clipping precision DWORD fdwQuality, // output quality DWORD fdwPitchAndFamily, // pitch and family LPCTSTR lpszFace // typeface name ); MFC (Visual C++) 将 HFONT 封装为 CFont BOOL CFont::CreateFont ( int nHeight, int nWidth, int nEscapement, int nOrientation
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有