CComboBox需要以不同的字体显示一些字体名称

编程入门 行业动态 更新时间:2024-10-27 09:47:46
本文介绍了CComboBox需要以不同的字体显示一些字体名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个CComboBox,当前以其对应的字体显示所有不同的可选字体.我用过的方法:

Hi, I have a CComboBox that currently displays all the different selectable fonts in their respsective fonts. I have used the method:

EnumFontFamiliesEx(.....)

,效果很好. 但是,我现在只需要显示其中一些字体选项.是否有一种简单的方法来选择例如Arial,Calibri,Times New Roman要以自己的字体显示在组合框中吗? 我找不到使用EnumFontFamiliesEx方法执行此操作的方法,因此我尝试使用以下代码,但是尽管添加了字符串"Arial"(MyComboBox类为源自CComboBox):

and it works great. However, I now need to only show a few of these font options. Is there an easy way to just select e.g. Arial, Calibri, Times New Roman to be displayed in the combobox in their own fonts? I couldn''t find a way to do this using the EnumFontFamiliesEx method so I tried to use the following code, but it did not change the font style shown in the combo box, although the string "Arial" was added (MyComboBox class is derived from CComboBox):

void MyComboBoxClass::SetFonts() { CFont font; font.CreatePointFont80,"Arial"); SetFont(&font); CClientDC dc(this); dc.SelectObject(&font); AddString("Arial");

我将组合框的所有者绘制设置更改为所有选项,但没有任何帮助. 有没有简单的方法可以做我想做的事情,或者有人可以帮助我找出复杂的方法吗? 非常感谢您的帮助.

I changed the owner draw setting of the combo box to all its options and nothing helped. Is there a simple way to do what I am trying to do, or can someone help me figure out the complicated way please? Very many thanks in advance for any help.

推荐答案

我没有适合您的解决方案,但请看一下CMFCFontCombBox控件(VS2008 +功能包)或更高版本),它可能并不完全适合您,但这可能是一个不错的开始. 另外,我不明白,您是否手动填写组合框并自己显示项目? 在这种情况下,为什么不能仅使用EnumFontFamiliesEx并过滤(或过滤)要使用的字体? 祝你好运. I don''t have a solution for you, but have a look at the CMFCFontCombBox control (VS2008+feature pack or later), it might not exactly work for you, but it could be a good start. Also, I don''t understand, do you manually fill a combo box and display the items yourself? If that is the case, why can''t use just still use EnumFontFamiliesEx and filter in (or out) the fonts you want to use? Good luck.

更多推荐

CComboBox需要以不同的字体显示一些字体名称

本文发布于:2023-11-04 21:50:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559106.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字体   名称   CComboBox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!