在CStatic控件中设置不同的字体 [英] Setting different fonts in CStatic control

查看:281
本文介绍了在CStatic控件中设置不同的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试弄清楚如何在CStatic控件文本中进行设置,某些文本应使用一种字体,某些文本应使用另一种字体.我该怎么办?

Hello, i''m trying to figure it out how to set in CStatic control text and some text should be with one font and some text should be with another font. How can i do it?
Thanks in advance!

推荐答案

为此,您需要对CStatic控件进行子类化,然后可以根据需要通过处理WM_PAINT消息(OnPaint()在MFC中).我相信您可以在此站点上找到很多示例.如果找不到,我可以提供进一步的帮助.
To do this, you need to subclass CStatic control, then you can change whole drawing behavior as you need by handling WM_PAINT message (OnPaint() in MFC). I''m sure you can find lots of example in this site. If you can''t find, I can help further.


我只建议在有较大更改的情况下覆盖OnPaint(),不值得仅创建一个类来更改字体.

这里有两种更好的方法(而不是仅仅为了更改字体而覆盖OnPaint()):
http://www.codeproject.com/Messages/3064309/Control-CStatic- Height-of-FONT.aspx [ ^ ]
http://www.dotnetheaven.com/Uploadfile/mahesh/font04272005052608AM/font.aspx [ ^ ]
I would only recommend overwriting OnPaint() if there''s big changes, its not worth creating a class just to change the font.

Here''s a couple of better ways (rather than overwriting the OnPaint() just to change the font):
http://www.codeproject.com/Messages/3064309/Control-CStatic-Height-of-FONT.aspx[^]
http://www.dotnetheaven.com/Uploadfile/mahesh/font04272005052608AM/font.aspx[^]


这篇关于在CStatic控件中设置不同的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆