Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 28-Apr-14 4:26am
v2

1 solution

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
 
Share this answer
 
Comments
AlwaysLearningNewStuff 27-Apr-14 13:46pm    
Thank you for your advice.

I have subclassed edit controls to accept appropriate characters.

I am performing validity check using strtod/strtol in response to EN_CHANGE. I test input there for each edit control ( I saw no other way ) and do MessageBeep(MB_ICINERROR); if input is invalid. I also disable the button as you have suggested ( I am so glad that we see things from similar perspective ).

Still, if multiple entries are invalid, it would help the user to somehow see which ones need to be corrected. That is why I thought to add a visual indicator.

Does this make any sense?

Thank you.

Best regards.
Sergey Alexandrovich Kryukov 27-Apr-14 18:32pm    
Yes, it does. How about disabling the some other control like a button related to the use of the data when it is invalid?
—SA
AlwaysLearningNewStuff 27-Apr-14 19:28pm    
I have already done that.

If edit control's text is invalid, I disable "Save" button and play a sound, so user can realize that input is wrong.

Still, I would also like to make it visually pointed out, like changing the background color of that edit control for example.

Best regards.
Sergey Alexandrovich Kryukov 27-Apr-14 19:42pm    
Well, it may make sense. I would suggest you follow your own taste, but playing a sound can be irritating to most users...
—SA
AlwaysLearningNewStuff 27-Apr-14 19:54pm    
That is why I wish to substitute the beep with a visual indicator.

I guess changing the background color of the edit control would be the wisest, but I have ran into difficulties trying to do so.

Can you provide me a small example that successfully does that? Or can you give me instructions?

Thank you.

Best regards.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900