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. Need MFC Combo Box Help [modified]

Need MFC Combo Box Help [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++helpquestionannouncement
5 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.
  • C Offline
    C Offline
    CoffeeAddict19
    wrote on last edited by
    #1

    I've got an MFC dialog box with a combo box and several text boxes. I have to know what item in the combo box is selected in order to display the right content in the text boxes. Right now I have it set up so that when the user clicks a button it executes this segment: CurrentSelection = ComboBoxPtr->GetCurSel(); CurrentContact = m_pMainWnd->OperationsClass.PhoneBookClass.ReturnContact(CurrentSelection); //update text boxes based on name combo box selection UpdateContactTextBoxes(CurrentSelection); How can is I set it up so that it will detect when the user makes a change in the combo box, gets the current selection, and automatically executes UpdateContactTextBoxes(CurrentSelection), all without using a button? I saw a tutorial on how to do it with a wizard, but can anyone tell me how to do it with straight MFC code? I hate wizards.

    A V N 3 Replies Last reply
    0
    • C CoffeeAddict19

      I've got an MFC dialog box with a combo box and several text boxes. I have to know what item in the combo box is selected in order to display the right content in the text boxes. Right now I have it set up so that when the user clicks a button it executes this segment: CurrentSelection = ComboBoxPtr->GetCurSel(); CurrentContact = m_pMainWnd->OperationsClass.PhoneBookClass.ReturnContact(CurrentSelection); //update text boxes based on name combo box selection UpdateContactTextBoxes(CurrentSelection); How can is I set it up so that it will detect when the user makes a change in the combo box, gets the current selection, and automatically executes UpdateContactTextBoxes(CurrentSelection), all without using a button? I saw a tutorial on how to do it with a wizard, but can anyone tell me how to do it with straight MFC code? I hate wizards.

      A Offline
      A Offline
      Aqueel
      wrote on last edited by
      #2

      Use events associated with the combo box.

      We Believe in Excellence www.aqueelmirza.cjb.net

      1 Reply Last reply
      0
      • C CoffeeAddict19

        I've got an MFC dialog box with a combo box and several text boxes. I have to know what item in the combo box is selected in order to display the right content in the text boxes. Right now I have it set up so that when the user clicks a button it executes this segment: CurrentSelection = ComboBoxPtr->GetCurSel(); CurrentContact = m_pMainWnd->OperationsClass.PhoneBookClass.ReturnContact(CurrentSelection); //update text boxes based on name combo box selection UpdateContactTextBoxes(CurrentSelection); How can is I set it up so that it will detect when the user makes a change in the combo box, gets the current selection, and automatically executes UpdateContactTextBoxes(CurrentSelection), all without using a button? I saw a tutorial on how to do it with a wizard, but can anyone tell me how to do it with straight MFC code? I hate wizards.

        V Offline
        V Offline
        VCSharp007
        wrote on last edited by
        #3

        Just add a handler to CBN_SELCHANGE message and put your code there..

        1 Reply Last reply
        0
        • C CoffeeAddict19

          I've got an MFC dialog box with a combo box and several text boxes. I have to know what item in the combo box is selected in order to display the right content in the text boxes. Right now I have it set up so that when the user clicks a button it executes this segment: CurrentSelection = ComboBoxPtr->GetCurSel(); CurrentContact = m_pMainWnd->OperationsClass.PhoneBookClass.ReturnContact(CurrentSelection); //update text boxes based on name combo box selection UpdateContactTextBoxes(CurrentSelection); How can is I set it up so that it will detect when the user makes a change in the combo box, gets the current selection, and automatically executes UpdateContactTextBoxes(CurrentSelection), all without using a button? I saw a tutorial on how to do it with a wizard, but can anyone tell me how to do it with straight MFC code? I hate wizards.

          N Offline
          N Offline
          Nibu babu thomas
          wrote on last edited by
          #4

          CoffeeAddict19 wrote:

          How can is I set it up so that it will detect when the user makes a change in the combo box,

          Use CBN_SELENDOK.


          Nibu thomas A Developer Programming tips[^]  My site[^]

          C 1 Reply Last reply
          0
          • N Nibu babu thomas

            CoffeeAddict19 wrote:

            How can is I set it up so that it will detect when the user makes a change in the combo box,

            Use CBN_SELENDOK.


            Nibu thomas A Developer Programming tips[^]  My site[^]

            C Offline
            C Offline
            CoffeeAddict19
            wrote on last edited by
            #5

            Thanks for your help. I got it working now. :)

            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