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. Problem in Accessing CStringArray object,

Problem in Accessing CStringArray object,

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelpquestion
10 Posts 7 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.
  • A Offline
    A Offline
    Atul23
    wrote on last edited by
    #1

    Hi All, I am using CStringArray object to store the strings in array. I used this object in one class where i add strings in to CStringArray object. I want to access this object in other class. But when i access it in other class it gives me garbage values. So how can i access it in another class. Atul

    M H D A 4 Replies Last reply
    0
    • A Atul23

      Hi All, I am using CStringArray object to store the strings in array. I used this object in one class where i add strings in to CStringArray object. I want to access this object in other class. But when i access it in other class it gives me garbage values. So how can i access it in another class. Atul

      M Offline
      M Offline
      Matthew Faithfull
      wrote on last edited by
      #2

      There should be no problem doing this. It sounds like your CStringArray may have been delete before the second access. Is it a member variable of an object that's gone out of scope or did you create it on the stack?

      Nothing is exactly what it seems but everything with seems can be unpicked.

      1 Reply Last reply
      0
      • A Atul23

        Hi All, I am using CStringArray object to store the strings in array. I used this object in one class where i add strings in to CStringArray object. I want to access this object in other class. But when i access it in other class it gives me garbage values. So how can i access it in another class. Atul

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

        Do you want to access CStringArray on the other dialogs?

        1 Reply Last reply
        0
        • A Atul23

          Hi All, I am using CStringArray object to store the strings in array. I used this object in one class where i add strings in to CStringArray object. I want to access this object in other class. But when i access it in other class it gives me garbage values. So how can i access it in another class. Atul

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

          Atul23 wrote:

          But when i access it in other class...

          How?


          "A good athlete is the result of a good and worthy opponent." - David Crow

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

          1 Reply Last reply
          0
          • A Atul23

            Hi All, I am using CStringArray object to store the strings in array. I used this object in one class where i add strings in to CStringArray object. I want to access this object in other class. But when i access it in other class it gives me garbage values. So how can i access it in another class. Atul

            A Offline
            A Offline
            aks
            wrote on last edited by
            #5

            could you pls explain the prblm.

            Ajay

            H 1 Reply Last reply
            0
            • A aks

              could you pls explain the prblm.

              Ajay

              H Offline
              H Offline
              Hadi Dayvary
              wrote on last edited by
              #6

              I have a program that have a lot of dialogs and so a lot of butons. I wanna use my own button in all the dialogs, but I don't want to add a variable for each button on dialogs. I wnat to do it in just one piece of code, something like this : (in InitDialog()) CWnd* pWnd = GetWindow(GW_CHILD); while(pWnd) { if(pWnd->GetRuntimeClass() != RUNTIME_CLASS(CButton)) ;// - change them to CMyButton pWnd = pWnd->GetWindow(GW_HWNDNEXT); }

              D 1 Reply Last reply
              0
              • H Hadi Dayvary

                I have a program that have a lot of dialogs and so a lot of butons. I wanna use my own button in all the dialogs, but I don't want to add a variable for each button on dialogs. I wnat to do it in just one piece of code, something like this : (in InitDialog()) CWnd* pWnd = GetWindow(GW_CHILD); while(pWnd) { if(pWnd->GetRuntimeClass() != RUNTIME_CLASS(CButton)) ;// - change them to CMyButton pWnd = pWnd->GetWindow(GW_HWNDNEXT); }

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

                Hadi Dayvary wrote:

                ...but I don't want to add a variable for each button on dialogs.

                Why not?


                "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

                H 1 Reply Last reply
                0
                • D David Crow

                  Hadi Dayvary wrote:

                  ...but I don't want to add a variable for each button on dialogs.

                  Why not?


                  "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

                  H Offline
                  H Offline
                  Hadi Dayvary
                  wrote on last edited by
                  #8

                  because there are more than 500 buttons in the project and they are growing, If there is a better way I like to use it. I think Professional UI use that way.

                  D 1 Reply Last reply
                  0
                  • H Hadi Dayvary

                    because there are more than 500 buttons in the project and they are growing, If there is a better way I like to use it. I think Professional UI use that way.

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

                    It would take all of 10 seconds to change all references from CButton to CMyButton using search/replace in the IDE. You've spent 100 times that just looking for a solution, let alone implementing one.


                    "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

                      It would take all of 10 seconds to change all references from CButton to CMyButton using search/replace in the IDE. You've spent 100 times that just looking for a solution, let alone implementing one.


                      "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
                      ThatsAlok
                      wrote on last edited by
                      #10

                      DavidCrow wrote:

                      It would take all of 10 seconds to change all references from CButton to CMyButton using search/replace in the IDE. You've spent 100 times that just looking for a solution, let alone implementing one.

                      thats what we call.. a great reply!

                      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
                      Never mind - my own stupidity is the source of every "problem" - Mixture

                      cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

                      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