推荐用于在单行编辑控件中直观显示无效输入的解决方案 [英] Recommend solution for visually indicating invalid input in singleline edit control

查看:155
本文介绍了推荐用于在单行编辑控件中直观显示无效输入的解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在对话框中编辑控件。其中一些是数字的,有些是接受浮点数,有些是文本的。



我用整数和浮点输入验证编辑控件。



我已经实施了验证机制以响应 EN_CHANGE 消息。我使用 MessageBeep(MB_ICONERROR); 表示无效输入。



我还想在视觉上表明错误,但不知道该怎么做。



因为我有多个编辑控件(15),所以最佳选择似乎改变了画笔响应 WM_CTLCOLOREDIT 但我担心这个解决方案会引入太多新变量。另一种选择似乎是工具提示,但如果多个编辑控件具有无效输入,则这看起来可能看起来没有吸引力。这就是为什么我在这里寻求帮助,所以我可以从经验丰富,比我更好的开发人员那里得到建议。



对我来说最好的解决方案是什么? ,当用户进行一次或多次无效输入时,可视地指示错误?



谢谢。



最好的问候。

解决方案

我要小心不要对这种指示施加我自己的意见,因为这取决于个人品味,是一个问题争论。也许你可以选择适合你的应用的东西。



这里有一些你需要考虑的项目:



在某些简单的情况下,您可以找到一种使输入始终有效的方法,例如,如果您可以过滤掉不需要的字符。确保你永远不会使用更复杂的过滤器(例如,字符被过滤掉或不被过滤,具体取决于它在字符串中的位置或其他标准),它们只会让你的用户大为混淆。



可能是相反的情况,即使验证一个控件输入也是不可能的,因为验证标准取决于几个控件。这种情况比某些情况更频繁发生(这就是为什么我不想对单个控件的有效性指示给予太多关注的原因;它通常不能解决问题)。在这种情况下,请将注意力集中在最终需要使用控制数据的位置。例如,如果您需要在某个按钮上单击使用数据,请启用或禁用此按钮。这将需要验证每个控件的每个更改的所有内容,因此请考虑制作一些通用工具来涵盖这种情况。



-SA

I have edit controls in my dialog box. Some of them are numeric, some of them accept floats and some of them are textual.

I am validating edit control's with integer and float input.

I have implemented validation mechanism in response to EN_CHANGE message. I am using MessageBeep(MB_ICONERROR); to indicate invalid input.

I would also like to visually indicate error but do not know how to do it.

Since I have multiple edit controls ( 15 ) the best option seems to change the brush in response to WM_CTLCOLOREDIT but I fear this solution will introduce too many new variables. Another option seems to be tooltip, but if more than one edit control has invalid input this might look visually unappealing. That is why I am asking for help here, so I can get advice from experienced and better developers than myself.

What is the best solution for my case, to visually indicate error when user makes one or multiple invalid inputs ?

Thank you.

Best regards.

解决方案

I want to be careful about not pressing with my own opinion on such indication, because it depends on individual taste and is a matter of controversies. Perhaps you can choose something appropriate to your application.

Here are some items you would need to take into account:

In some simple cases, you can find a way of making input always valid, for example, if you can filter out unwanted characters. Make sure that you never use more complicated filter (for example, character is filtered out or not, depending on its position in string or other criteria), they would only greatly confuse your user.

It can be the opposite case, when even validation of one control input it impossible, because validation criteria depends on several controls. Such cases take place more often than some thing (and this is the reason why I don't want to pay much attention for the validity indication for a single control; it simply does not solve the problem in general). In this case, focus attention at the point where you need to ultimately use control data. For example, if you need to use data on some button click, enable or disable this button. This will require validation of everything on every change in each of controls, so think about making some universal facility to cover such situations.

—SA


这篇关于推荐用于在单行编辑控件中直观显示无效输入的解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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