如何检查Logfont结构是否有效? [英] How Can I Check If A Logfont Structure Is Valid?

查看:83
本文介绍了如何检查Logfont结构是否有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,



我正在开发一个小项目,用户可以通过CFontDialog选择字体。

当用户从ColorDialog中选择字体和颜色时,我将 LOGFONT Structure解析为一个简单的字符串,并将该字符串保存在文本字段中。

字符串的基本结构为 FaceName,size,color

示例: Arial,10,# 000000



在我下次打开CFontDialog之前,我将字符串解析回 LOGFONT 结构。



现在我不想写一个检查函数来检查字符串是否有效。

如果字符串包含无效字母,我跳过字符串的一部分,同时我将其解析回LOGFONT结构,并且Dialog显示初始值(如果size = nothing)。

但是什么如果我们的客户更改字体而不再打开CFontDialog?它很容易出错。



有没有人可以建议我一个方法,如何在不打开CFontDialog的情况下检查参数是否有效?

然后我可以在用户按下保存按钮时检查参数是否有效。



我知道这不是实现字体控件的最佳方式,但我的老板想要这样(我不明白为什么)

解决方案

使用 EnumFonts [ ^ ]检查字体名称是否有效的函数。

Hey guys,

i'm working on a small project where the user is able to choose a font via a CFontDialog.
When the User selects a Font and Color from the ColorDialog i'm parsing the LOGFONT Structure into a simple String and save this string in a text field.
The string have the basic structure "FaceName,size,color"
Sample: Arial,10,#000000

Before i open the CFontDialog the next time, i parse the string back into a LOGFONT structure.

Now i wan't to write a check function to check if the string is valid or not.
If the string contains invalid letters, i skip the part of the string while i parse it back to a LOGFONT structure, and the Dialog shows the initial values (in case of size = nothing).
But what if the our customer change the font and dont open the CFontDialog again? It's susceptible for errors.

Could anyone suggest me a way, how to check if the parameters are valid or not without opening the CFontDialog?
Then i could check if the parameter is valid when the user press the save button.

I know it is not the best way to implement a font control, but my boss want it this way (i have no idea why)

解决方案

Use the EnumFonts[^] function to check if the fontname is valid.


这篇关于如何检查Logfont结构是否有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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