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. Pass info class to class

Pass info class to class

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
4 Posts 2 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.
  • O Offline
    O Offline
    Oliver123
    wrote on last edited by
    #1

    Class CSDITest1Doc creates a new instance of a dialog class. Works OK. Example below: CTestDlg* aDlg = new CTestDlg(); //code is in CSDITest1Doc From class CSDITest1Doc I can execute functions of the new CTestDlg. For example, LoadMessage() is a function of CTestDlg. Works OK. Example below: aDlg->LoadMessage(); //this code is in CSDITest1Doc Sometimes I want to alert CSDITest1Doc of something that happens in CTestDlg. Sometimes I want CTestDlg to ask for data from CSDITest1Doc. Suppose XYZ() is a function of CSDITest1Doc. How do I execute a XYZ()of CSDITest1Doc from CTestDlg?

    D 1 Reply Last reply
    0
    • O Oliver123

      Class CSDITest1Doc creates a new instance of a dialog class. Works OK. Example below: CTestDlg* aDlg = new CTestDlg(); //code is in CSDITest1Doc From class CSDITest1Doc I can execute functions of the new CTestDlg. For example, LoadMessage() is a function of CTestDlg. Works OK. Example below: aDlg->LoadMessage(); //this code is in CSDITest1Doc Sometimes I want to alert CSDITest1Doc of something that happens in CTestDlg. Sometimes I want CTestDlg to ask for data from CSDITest1Doc. Suppose XYZ() is a function of CSDITest1Doc. How do I execute a XYZ()of CSDITest1Doc from CTestDlg?

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

      Oliver123 wrote:

      How do I execute a XYZ()of CSDITest1Doc from CTestDlg?

      One way is to pass a CSDITest1Doc pointer to the CTestDlg instance.


      "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

      O 1 Reply Last reply
      0
      • D David Crow

        Oliver123 wrote:

        How do I execute a XYZ()of CSDITest1Doc from CTestDlg?

        One way is to pass a CSDITest1Doc pointer to the CTestDlg instance.


        "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

        O Offline
        O Offline
        Oliver123
        wrote on last edited by
        #3

        I tried this, but found I didn't really know what to load into the pointer. In CSDITest1Doc I entered the following code. I figured if I could get the pointer aDoc loaded with the address of the instance of CSDITest1Doc, I could call a function from CTestDlg, and use that to pass the pointer to CTestDlg. CSDITest1Doc* aDoc; aDoc = ??????? Is this a correct approach? Thanks

        D 1 Reply Last reply
        0
        • O Oliver123

          I tried this, but found I didn't really know what to load into the pointer. In CSDITest1Doc I entered the following code. I figured if I could get the pointer aDoc loaded with the address of the instance of CSDITest1Doc, I could call a function from CTestDlg, and use that to pass the pointer to CTestDlg. CSDITest1Doc* aDoc; aDoc = ??????? Is this a correct approach? Thanks

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

          Oliver123 wrote:

          Is this a correct approach?

          No. Try:

          CTestDlg* aDlg = new CTestDlg(this); //code is in CSDITest1Doc

          Remember to create an appropriate CTestDlg constructor.


          "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

          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