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. Class to Class data transfer

Class to Class data transfer

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 3 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.
  • D Offline
    D Offline
    dipuks
    wrote on last edited by
    #1

    I have a class A, which is a dialog having a CEdit box with CString variable "m_Edit". I have another class B having a CString variable "str" declared in it. Now i want to make a call like this, CString str = m_Edit; This is to be done inside class B. How can i get the Edit box value in class A to class B CString "str". I tried a few things but couldn't make it work properly. Can anyone got any suggestions. Thanks in advance

    M V 2 Replies Last reply
    0
    • D dipuks

      I have a class A, which is a dialog having a CEdit box with CString variable "m_Edit". I have another class B having a CString variable "str" declared in it. Now i want to make a call like this, CString str = m_Edit; This is to be done inside class B. How can i get the Edit box value in class A to class B CString "str". I tried a few things but couldn't make it work properly. Can anyone got any suggestions. Thanks in advance

      M Offline
      M Offline
      Mark Greenwood
      wrote on last edited by
      #2

      easiest way is to define a function in ClassB which accepts a pointer to a CEdit i.e void CClassB::FixEdit(CEdit* pEdit) Then in that function you can set the text to the string i.e. void CClassB::FixEdit(CEdit* pEdit) { pEdit->SetWindowText(m_str); } How you call this up to you - but for example in the contructor of ClassA you could do the following CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT1); CClassB* cb = new CClassB(); cb->FixEdit(pEdit); You could make the function static then you would not need to instantiate the CClassB but that's up to you - likewise you could create a function which would take a CEdit pointer and you could then read the contents of the Edit Box instead

      1 Reply Last reply
      0
      • D dipuks

        I have a class A, which is a dialog having a CEdit box with CString variable "m_Edit". I have another class B having a CString variable "str" declared in it. Now i want to make a call like this, CString str = m_Edit; This is to be done inside class B. How can i get the Edit box value in class A to class B CString "str". I tried a few things but couldn't make it work properly. Can anyone got any suggestions. Thanks in advance

        V Offline
        V Offline
        vallikumar
        wrote on last edited by
        #3

        I think your m_Edit variable declared as public. otherwise make it public. then you should create an object for class A, inside class B. Like this A objA; then do the assignment statement... CString str = objA.m_Edit; :cool: regards Vallikumar A

        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