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. Combo Box Questions.

Combo Box Questions.

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
11 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.
  • S Suresh H

    Hello All, I have a Combo Box IDC_COMBO, & in the Combo Box Properties (data) , I have added 1,2,3 --- till 10 numbers. And in the code I have used below code to set the default Combo box value to 0. case WM_INITDIALOG: { HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO); SendMessage(hwndCombo,CB_SETITEMDATA,0,0); } break; Now the problem is its not showing the default value 0 on the dialog load and also combo box is empty ..its has no data ……its not showing numbers 1,2, ---10... Can anyone please help me & tell what is wrong ??? in the above code. Thanking you, Suresh HC. Edit/Delete Message

    H Offline
    H Offline
    Hamid Taebi
    wrote on last edited by
    #2

    In the property window of combobox you insert 1,2,3 or 1;2;3;


    WhiteSky


    S 1 Reply Last reply
    0
    • H Hamid Taebi

      In the property window of combobox you insert 1,2,3 or 1;2;3;


      WhiteSky


      S Offline
      S Offline
      Suresh H
      wrote on last edited by
      #3

      Hello WhiteSky, Thanks for the responce, i did that added again 1,2,3,4 but still its not diaplying them , combo box has no data its empty. can u please tell what is wrong here????

      H 1 Reply Last reply
      0
      • S Suresh H

        Hello WhiteSky, Thanks for the responce, i did that added again 1,2,3,4 but still its not diaplying them , combo box has no data its empty. can u please tell what is wrong here????

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #4

        You must use of ; not ,


        WhiteSky


        S 1 Reply Last reply
        0
        • H Hamid Taebi

          You must use of ; not ,


          WhiteSky


          S Offline
          S Offline
          Suresh H
          wrote on last edited by
          #5

          No its not working I tried with both , and also ; . actually I am working on win32 api and not MFC.

          H 1 Reply Last reply
          0
          • S Suresh H

            Hello All, I have a Combo Box IDC_COMBO, & in the Combo Box Properties (data) , I have added 1,2,3 --- till 10 numbers. And in the code I have used below code to set the default Combo box value to 0. case WM_INITDIALOG: { HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO); SendMessage(hwndCombo,CB_SETITEMDATA,0,0); } break; Now the problem is its not showing the default value 0 on the dialog load and also combo box is empty ..its has no data ……its not showing numbers 1,2, ---10... Can anyone please help me & tell what is wrong ??? in the above code. Thanking you, Suresh HC. Edit/Delete Message

            P Offline
            P Offline
            prasad_som
            wrote on last edited by
            #6

            Suresh H wrote:

            And in the code I have used below code to set the default Combo box value to 0. case WM_INITDIALOG: { HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO); SendMessage(hwndCombo,CB_SETITEMDATA,0,0); } break;

            You are using wrong message for setting value.CB_SETITEMDATA is used to set item data for particular index. I'm not clear about your wording, I'm assuming that you want first value to be selected and default selection. You do this by using,

            HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO);
            SendMessage(hwndCombo,CB_CB_SETCURSEL,0,0);

            Prasad Notifier using ATL | Operator new[],delete[][^]

            S 1 Reply Last reply
            0
            • S Suresh H

              No its not working I tried with both , and also ; . actually I am working on win32 api and not MFC.

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #7

              If you use of CB_ADDSTRING for insert data to combobox instead property window what happens?


              WhiteSky


              S 1 Reply Last reply
              0
              • P prasad_som

                Suresh H wrote:

                And in the code I have used below code to set the default Combo box value to 0. case WM_INITDIALOG: { HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO); SendMessage(hwndCombo,CB_SETITEMDATA,0,0); } break;

                You are using wrong message for setting value.CB_SETITEMDATA is used to set item data for particular index. I'm not clear about your wording, I'm assuming that you want first value to be selected and default selection. You do this by using,

                HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO);
                SendMessage(hwndCombo,CB_CB_SETCURSEL,0,0);

                Prasad Notifier using ATL | Operator new[],delete[][^]

                S Offline
                S Offline
                Suresh H
                wrote on last edited by
                #8

                Hello Prasad, Thanks for the responce. HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO); SendMessage(hwndCombo,CB_SETCURSEL,0,0); Actually I have added numbers from 0– 10 in the Combo box properties under data. After the dialog load combo box is empty no values in that . can u plz tell me what is wrong ??? Yes I want the default value to be selected to 0.

                1 Reply Last reply
                0
                • H Hamid Taebi

                  If you use of CB_ADDSTRING for insert data to combobox instead property window what happens?


                  WhiteSky


                  S Offline
                  S Offline
                  Suresh H
                  wrote on last edited by
                  #9

                  Whitesky cant we enter the default data in the combo box which we do in the MFC, where we enter the data in properties.. In api I have to enter each data to the combo box by code ??? using add string ??

                  1 Reply Last reply
                  0
                  • S Suresh H

                    Hello All, I have a Combo Box IDC_COMBO, & in the Combo Box Properties (data) , I have added 1,2,3 --- till 10 numbers. And in the code I have used below code to set the default Combo box value to 0. case WM_INITDIALOG: { HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO); SendMessage(hwndCombo,CB_SETITEMDATA,0,0); } break; Now the problem is its not showing the default value 0 on the dialog load and also combo box is empty ..its has no data ……its not showing numbers 1,2, ---10... Can anyone please help me & tell what is wrong ??? in the above code. Thanking you, Suresh HC. Edit/Delete Message

                    M Offline
                    M Offline
                    Michael Dunn
                    wrote on last edited by
                    #10

                    That properties page where you enter the initial data for the combo box only works in MFC apps.

                    --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ");

                    S 1 Reply Last reply
                    0
                    • M Michael Dunn

                      That properties page where you enter the initial data for the combo box only works in MFC apps.

                      --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ");

                      S Offline
                      S Offline
                      Suresh H
                      wrote on last edited by
                      #11

                      Thanks Mike.

                      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