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. VC++ 6.0 question newbie question

VC++ 6.0 question newbie question

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
13 Posts 5 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.
  • J johnny alpaca

    I have a CListBox in which I display a string using the AddString function For the CString I use it's Format Function CListBox List1; CString str; short Data[50]; int DataSize ; /* variable */ DataSize = /*some processing */ for ( i=0;i<j;i++) { /* some other processing*/ str.Format("%X ",Data[i]); List1.AddString(str); } My current code Data is outputed in this manner 05 25 6F E2 I want my display to be like this : Contents of Data[DataSize-1] Contents of Data[DataSize-2] .... Data[0] e.g if Data[0]= 05 Data[1]= 25 Data[2]=6F and Data[3]= E2 Display I want is E2 6F 25 05 (ie in the same line ) How do I go about doing it ? any help woould be appreciated

    R Offline
    R Offline
    Rajkumar R
    wrote on last edited by
    #2

    Use AppendFormat() in place of Format(). And Addstring to the list when you complete the line. And Are you expecting data in separate column?

    J 2 Replies Last reply
    0
    • R Rajkumar R

      Use AppendFormat() in place of Format(). And Addstring to the list when you complete the line. And Are you expecting data in separate column?

      J Offline
      J Offline
      johnny alpaca
      wrote on last edited by
      #3

      Is AppendFormat present CString Function in VC++ 6.0 ?

      R 1 Reply Last reply
      0
      • J johnny alpaca

        Is AppendFormat present CString Function in VC++ 6.0 ?

        R Offline
        R Offline
        Rajkumar R
        wrote on last edited by
        #4

        Are you expecting data in separate column?

        1 Reply Last reply
        0
        • R Rajkumar R

          Use AppendFormat() in place of Format(). And Addstring to the list when you complete the line. And Are you expecting data in separate column?

          J Offline
          J Offline
          johnny alpaca
          wrote on last edited by
          #5

          I want data to displayed like this 25 4E 20 F6 .... (for example) and not like this 25 4E 20 F6 ( I dont want for it to displayed in Different rows but all in the same row)

          R 1 Reply Last reply
          0
          • J johnny alpaca

            I want data to displayed like this 25 4E 20 F6 .... (for example) and not like this 25 4E 20 F6 ( I dont want for it to displayed in Different rows but all in the same row)

            R Offline
            R Offline
            Rajkumar R
            wrote on last edited by
            #6

            Then I am not sure AppendFormat is supported in VS 6.0. But i think it should have concatenation operator. Format using temp variable and concatenate to main string. If want in separate column go for ListView control, CListCtrl.

            1 Reply Last reply
            0
            • J johnny alpaca

              I have a CListBox in which I display a string using the AddString function For the CString I use it's Format Function CListBox List1; CString str; short Data[50]; int DataSize ; /* variable */ DataSize = /*some processing */ for ( i=0;i<j;i++) { /* some other processing*/ str.Format("%X ",Data[i]); List1.AddString(str); } My current code Data is outputed in this manner 05 25 6F E2 I want my display to be like this : Contents of Data[DataSize-1] Contents of Data[DataSize-2] .... Data[0] e.g if Data[0]= 05 Data[1]= 25 Data[2]=6F and Data[3]= E2 Display I want is E2 6F 25 05 (ie in the same line ) How do I go about doing it ? any help woould be appreciated

              O Offline
              O Offline
              Ozer Karaagac
              wrote on last edited by
              #7

              You can concatenate all hex. digits in one string. As shown below: CString strLine; for ( i=0;i { /* some other processing*/ str.Format("%X ",Data[i]); strLine += str; } List1.AddString(strLine); In this approach, you can also use tab ('\t') separator char. between numbers, then you can use CListBox::SetTabStops() function in order to display it properly. If you want to have real tabular view, you can employ CListCtrl (list view control) instead of CListBox.

              J 1 Reply Last reply
              0
              • J johnny alpaca

                I have a CListBox in which I display a string using the AddString function For the CString I use it's Format Function CListBox List1; CString str; short Data[50]; int DataSize ; /* variable */ DataSize = /*some processing */ for ( i=0;i<j;i++) { /* some other processing*/ str.Format("%X ",Data[i]); List1.AddString(str); } My current code Data is outputed in this manner 05 25 6F E2 I want my display to be like this : Contents of Data[DataSize-1] Contents of Data[DataSize-2] .... Data[0] e.g if Data[0]= 05 Data[1]= 25 Data[2]=6F and Data[3]= E2 Display I want is E2 6F 25 05 (ie in the same line ) How do I go about doing it ? any help woould be appreciated

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #8

                it's because you're using a List control, and you're setting each string on a line. you have to build the single string, and do the List1.AddString() after the for() loop...

                [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                D 1 Reply Last reply
                0
                • T toxcct

                  it's because you're using a List control, and you're setting each string on a line. you have to build the single string, and do the List1.AddString() after the for() loop...

                  [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

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

                  toxcct wrote:

                  it's because you're using a List control...

                  How did you infer this?

                  "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  T 1 Reply Last reply
                  0
                  • D David Crow

                    toxcct wrote:

                    it's because you're using a List control...

                    How did you infer this?

                    "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    T Offline
                    T Offline
                    toxcct
                    wrote on last edited by
                    #10

                    DavidCrow wrote:

                    How did you infer this?

                    List1.AddString() is explicit enough...

                    [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                    D 1 Reply Last reply
                    0
                    • O Ozer Karaagac

                      You can concatenate all hex. digits in one string. As shown below: CString strLine; for ( i=0;i { /* some other processing*/ str.Format("%X ",Data[i]); strLine += str; } List1.AddString(strLine); In this approach, you can also use tab ('\t') separator char. between numbers, then you can use CListBox::SetTabStops() function in order to display it properly. If you want to have real tabular view, you can employ CListCtrl (list view control) instead of CListBox.

                      J Offline
                      J Offline
                      johnny alpaca
                      wrote on last edited by
                      #11

                      thanks that does it I am new to C++

                      1 Reply Last reply
                      0
                      • T toxcct

                        DavidCrow wrote:

                        How did you infer this?

                        List1.AddString() is explicit enough...

                        [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

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

                        Isn't Addstring() for listboxes?

                        "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                        T 1 Reply Last reply
                        0
                        • D David Crow

                          Isn't Addstring() for listboxes?

                          "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                          T Offline
                          T Offline
                          toxcct
                          wrote on last edited by
                          #13

                          DavidCrow wrote:

                          Isn't Addstring() for listboxes?

                          and what did I say ? i said *a* List *Control*, not meaning CListCtrl in particular, but a control which managed datas as a list...

                          [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                          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