Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CCombobox MFC vc++

CCombobox MFC vc++

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_14575556
    wrote on last edited by
    #1

    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.

    L _ D 3 Replies Last reply
    0
    • M Member_14575556

      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.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • M Member_14575556

        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.

        _ Offline
        _ Offline
        _Flaviu
        wrote on last edited by
        #3

        Depending of your CComboBox style, you can check either

        if(CB_ERR == m_combo.GetCurSel())
        {
        // no selection
        }

        or

        CString sValue;
        m_ComboBox.GetWindowText(sValue);
        if(sValue.IsEmpty())
        {
        // no selection
        }

        1 Reply Last reply
        0
        • M Member_14575556

          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.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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

          L 1 Reply Last reply
          0
          • D David Crow

            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

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            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

            D 1 Reply Last reply
            0
            • L Lost User

              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

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups