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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. AddString() fails, WHY???

AddString() fails, WHY???

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

    I try to manipulate strings of a combox dropdown list, codes as shown below: ((CComboBox *)GetDlgItem(IDC_COMBOBOX))->DeleteString(1); ((CComboBox *)GetDlgItem(IDC_COMBOBOX))->AddString(CString("hello")); ((CComboBox *)GetDlgItem(IDC_COMBOBOX))->InsertString(-1, CString("hello")); The first line works, but the second and third lines fails (nothing happens there, the program can go on executing). WHY??? So frustrating! Did i need to do something before adding/inserting a string? Thanks a lot!!! Wenrich

    C C R W 4 Replies Last reply
    0
    • W Wenrich

      I try to manipulate strings of a combox dropdown list, codes as shown below: ((CComboBox *)GetDlgItem(IDC_COMBOBOX))->DeleteString(1); ((CComboBox *)GetDlgItem(IDC_COMBOBOX))->AddString(CString("hello")); ((CComboBox *)GetDlgItem(IDC_COMBOBOX))->InsertString(-1, CString("hello")); The first line works, but the second and third lines fails (nothing happens there, the program can go on executing). WHY??? So frustrating! Did i need to do something before adding/inserting a string? Thanks a lot!!! Wenrich

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      your code is OK. what is the return value from AddString? -c


      Alcohol is the anesthesia by which we endure the operation of life. -- George Bernard Shaw

      Smaller Animals Software

      W 1 Reply Last reply
      0
      • C Chris Losinger

        your code is OK. what is the return value from AddString? -c


        Alcohol is the anesthesia by which we endure the operation of life. -- George Bernard Shaw

        Smaller Animals Software

        W Offline
        W Offline
        Wenrich
        wrote on last edited by
        #3

        return value from both AddString() and InsertString() is 0; but it's supposed to be inserted at the end, therefore should be some positive value(my combox is not empty). Any more information? Thanks!!!!!!!

        1 Reply Last reply
        0
        • W Wenrich

          I try to manipulate strings of a combox dropdown list, codes as shown below: ((CComboBox *)GetDlgItem(IDC_COMBOBOX))->DeleteString(1); ((CComboBox *)GetDlgItem(IDC_COMBOBOX))->AddString(CString("hello")); ((CComboBox *)GetDlgItem(IDC_COMBOBOX))->InsertString(-1, CString("hello")); The first line works, but the second and third lines fails (nothing happens there, the program can go on executing). WHY??? So frustrating! Did i need to do something before adding/inserting a string? Thanks a lot!!! Wenrich

          C Offline
          C Offline
          Carlos Antollini
          wrote on last edited by
          #4

          You get an error, or only you can not see the strings? Regards Carlos Antollini. Pi Five Creator Sonork ID 100.10529 cantollini

          1 Reply Last reply
          0
          • W Wenrich

            I try to manipulate strings of a combox dropdown list, codes as shown below: ((CComboBox *)GetDlgItem(IDC_COMBOBOX))->DeleteString(1); ((CComboBox *)GetDlgItem(IDC_COMBOBOX))->AddString(CString("hello")); ((CComboBox *)GetDlgItem(IDC_COMBOBOX))->InsertString(-1, CString("hello")); The first line works, but the second and third lines fails (nothing happens there, the program can go on executing). WHY??? So frustrating! Did i need to do something before adding/inserting a string? Thanks a lot!!! Wenrich

            R Offline
            R Offline
            RalfPeter
            wrote on last edited by
            #5

            If you haven't already, try doing what you did in CMyDialog::OnInitiateDialog() member function. ralf.riedel@usm.edu

            1 Reply Last reply
            0
            • W Wenrich

              I try to manipulate strings of a combox dropdown list, codes as shown below: ((CComboBox *)GetDlgItem(IDC_COMBOBOX))->DeleteString(1); ((CComboBox *)GetDlgItem(IDC_COMBOBOX))->AddString(CString("hello")); ((CComboBox *)GetDlgItem(IDC_COMBOBOX))->InsertString(-1, CString("hello")); The first line works, but the second and third lines fails (nothing happens there, the program can go on executing). WHY??? So frustrating! Did i need to do something before adding/inserting a string? Thanks a lot!!! Wenrich

              W Offline
              W Offline
              Wenrich
              wrote on last edited by
              #6

              It's strange, isn't it? HELP!

              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