MFC文本字体大小,颜色

一只正在啃的蜗牛 2018-10-15 05:04:15
CFont mFnt;
LOGFONT mLogFont;
memset(&mLogFont,0,sizeof(LOGFONT));
strcpy_s(mLogFont.lfFaceName,"Arial");
mLogFont.lfHeight=130;
mLogFont.lfWeight=FW_SEMIBOLD;
mFnt.CreatePointFontIndirect(&mLogFont);
pDC->SelectObject(&mFnt);

mLogFont.lfFaceName什么意思
FW_SEMIBOLD什么意思
CreatePointFontIndirect怎么解释
...全文
336 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
绿色盒子 2018-10-17
  • 打赏
  • 举报
回复
MSDN是个好东西
mLogFont.lfFaceName:字体名称 如“宋体”
FW_SEMIBOLD:字体权重600 字体的权重范围为0到1000.例如,400表示正常,700表示粗体。如果此值为零,则使用默认权重。
CreatePointFontIndirect:初始化CFont对象中给定的特征LOGFONT结构。与相同CreateFontIndirect不同之处在于字体高度以点而不是逻辑单元的十分之几。
みしつかん 2018-10-16
  • 打赏
  • 举报
回复
mLogFont.lfFaceName 这里代表给mLogFont这个结构体的成员lfFaceName复制,表示字体的名字
FW_SEMIBOLD 这就是一个宏定义,值是600,代表字体的宽度,可理解为加粗的程度
CreatePointFontIndirect 表示用mLogFont这种字体结构体初始化CFont对象mFnt
Eleven 2018-10-16
  • 打赏
  • 举报
回复
请参考MSDN文档~~~
赵4老师 2018-10-15
  • 打赏
  • 举报
回复
VS IDE中,在不明白的符号上点鼠标右键,选转到定义。
schlafenhamster 2018-10-15
  • 打赏
  • 举报
回复
CFont::CreatePointFontIndirect
BOOL CreatePointFontIndirect( const LOGFONT* lpLogFont, CDC* pDC = NULL );

Return Value

Nonzero if successful, otherwise 0.

Parameters

lpLogFont

Points to aLOGFONT structure that defines the characteristics of the logical font. The lfHeight member of the LOGFONT structure is measured in tenths of a point rather than logical units. (For instance, set lfHeight to 120 to request a 12-point font.)

pDC

Pointer to the CDC object to be used to convert the height in lfHeight to logical units. If NULL, a screen device context is used for the conversion.

Remarks

This function is the same as CreateFontIndirect except that the lfHeight member of the LOGFONT is interpreted in tenths of a point rather than device units. This function automatically converts the height in lfHeight to logical units using the CDC object pointed to by pDC before passing the LOGFONT structure on to Windows.

When you finish with the CFont object created by the CreatePointFontIndirect function, first select the font out of the device context, then delete the CFont object.

、、、、、
lfWeight
Specifies the weight of the font in the range 0 through 1000. For example, 400 is normal and 700 is bold. If this value is zero, a default weight is used.
The following values are defined for convenience: Value Weight
FW_DONTCARE 0
FW_THIN 100
FW_EXTRALIGHT 200
FW_ULTRALIGHT 200
FW_LIGHT 300
FW_NORMAL 400
FW_REGULAR 400
FW_MEDIUM 500
FW_SEMIBOLD 600
FW_DEMIBOLD 600
FW_BOLD 700
FW_EXTRABOLD 800
FW_ULTRABOLD 800
FW_HEAVY 900
FW_BLACK 900

。。。。。。
lfFaceName
A null-terminated string that specifies the typeface name of the font. The length of this string must not exceed 32 characters, including the null terminator. The EnumFontFamilies function can be used to enumerate the typeface names of all currently available fonts. If lfFaceName is an empty string, GDI uses the first font that matches the other specified attributes.

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧