CCombobox MFC vc++
-
There is a CComboBox with three string in dropdown. I want to pop up a message if I didn't select anything from the drop down and press a button. I tried checking using CComboBox variable like m_combo.IsEmpty() but it didn't work. How can I check whether it is empty or not.
-
There is a CComboBox with three string in dropdown. I want to pop up a message if I didn't select anything from the drop down and press a button. I tried checking using CComboBox variable like m_combo.IsEmpty() but it didn't work. How can I check whether it is empty or not.
Member 14575556 wrote:
it didn't work.
That does not help to understand your problem. Please provide precise details of your code and exactly what results you get. You appear to be building this project question by question in this forum. Time to take stock and do some internet searches, and reading of the online documentation for the MFC classes, many of which include sample code.
-
There is a CComboBox with three string in dropdown. I want to pop up a message if I didn't select anything from the drop down and press a button. I tried checking using CComboBox variable like m_combo.IsEmpty() but it didn't work. How can I check whether it is empty or not.
-
There is a CComboBox with three string in dropdown. I want to pop up a message if I didn't select anything from the drop down and press a button. I tried checking using CComboBox variable like m_combo.IsEmpty() but it didn't work. How can I check whether it is empty or not.
Member 14575556 wrote:
I want to pop up a message if I didn't select anything from the drop down and press a button.
Don't allow button to be "pressed" unless a selection is made. Allowing the button to be "pressed" if one or more controls are in error violates the basic principles of GUI design. Not to mention it is extremely annoying.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Member 14575556 wrote:
I want to pop up a message if I didn't select anything from the drop down and press a button.
Don't allow button to be "pressed" unless a selection is made. Allowing the button to be "pressed" if one or more controls are in error violates the basic principles of GUI design. Not to mention it is extremely annoying.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
That's not a given. Tying the validation to the button "click" ("record" validation) is a lot simpler than context / field validation. In this case, he would have to "disable" the button (to "not allow a press"), then enable it when a selection was made. The more fields, the more "options", the more complex the enabling / disabling logic. So, "it depends".
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.' ― Confucian Analects
-
That's not a given. Tying the validation to the button "click" ("record" validation) is a lot simpler than context / field validation. In this case, he would have to "disable" the button (to "not allow a press"), then enable it when a selection was made. The more fields, the more "options", the more complex the enabling / disabling logic. So, "it depends".
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.' ― Confucian Analects
Gerry Schmitz wrote:
Tying the validation to the button "click" ("record" validation) is a lot simpler than context / field validation.
True, but that does not make it right.
Gerry Schmitz wrote:
In this case, he would have to "disable" the button (to "not allow a press"), then enable it when a selection was made.
Which is extremely easy. A "balloon tip" on the OK button briefly telling why it is disabled makes it even more intuitive.
Gerry Schmitz wrote:
The more fields, the more "options", the more complex the enabling / disabling logic.
Only if done incorrectly. Yes, a common approach is to sprinkle enable/disable code all over the place to do that very thing, but that's what adds unnecessarily complex (and possibly unmaintainable) code.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles