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. CString, class problem

CString, class problem

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

    hello, I have a database program and i'm trying to get a CString variable from one class to work in another but i am getting strange results. It's dialog based and i made a new dialog class. I included the header files and it copiles with no errors but it spawns the main dialog when i try to use the string. (the string name is Value1 and its from the CChange class.)

    CChange change;
    m_edit1.SetWindowText(change.Value1);
    

    for some reason this launches the main dialog and does not work as a string. Any help would be much appreciated.

    R 1 Reply Last reply
    0
    • N no_life

      hello, I have a database program and i'm trying to get a CString variable from one class to work in another but i am getting strange results. It's dialog based and i made a new dialog class. I included the header files and it copiles with no errors but it spawns the main dialog when i try to use the string. (the string name is Value1 and its from the CChange class.)

      CChange change;
      m_edit1.SetWindowText(change.Value1);
      

      for some reason this launches the main dialog and does not work as a string. Any help would be much appreciated.

      R Offline
      R Offline
      Renjith Ramachandran
      wrote on last edited by
      #2

      Actually what you want, You need a CString Value from child dialog to fill an edit control in parent dialog? Assume CChildDlg is your child and CParentDlg is your parent dialog clasess Let m_EditValue is the name of the Edit control variable in your parent Dlg, m_csChildStringVariable is the CString variable in your child dialog declared as public then in parent dialog: void CParentDlg ::OnOk() { CChildDlg oChild; oChild.DoModal(); /*from that dialog you get some value for csChildStringVariable */ // set parent edit control CString csTemp = oChild.m_csChildStringVariable; m_EditValue.SetWindowText(csTemp ); } try that.. I want to change Myself..Can u help me? :)

      N 1 Reply Last reply
      0
      • R Renjith Ramachandran

        Actually what you want, You need a CString Value from child dialog to fill an edit control in parent dialog? Assume CChildDlg is your child and CParentDlg is your parent dialog clasess Let m_EditValue is the name of the Edit control variable in your parent Dlg, m_csChildStringVariable is the CString variable in your child dialog declared as public then in parent dialog: void CParentDlg ::OnOk() { CChildDlg oChild; oChild.DoModal(); /*from that dialog you get some value for csChildStringVariable */ // set parent edit control CString csTemp = oChild.m_csChildStringVariable; m_EditValue.SetWindowText(csTemp ); } try that.. I want to change Myself..Can u help me? :)

        N Offline
        N Offline
        no_life
        wrote on last edited by
        #3

        Well, actually im trying to get a string from the parent dialog to fill a child dialog edit box. I took your suggestion, but for some reason when i hit the button, it opens the main dialog. In the parent dialog i have:

        Value1="test";
        
        CChange change;
        change.DoModal();
        

        then in the child i did:

        CMainDlg maindlg;
        m_edit1.SetWindowText(maindlg.Value1);
        m_edit1.UpdateWindow();	
        

        when i hit the button, it launches the main dialog window as if it were opening the program again ! ? The reason i want this function is so that i can double click an entry in the listctrl and have it open with the strings in edit boxes, so that you can edit them and make changes.

        R 1 Reply Last reply
        0
        • N no_life

          Well, actually im trying to get a string from the parent dialog to fill a child dialog edit box. I took your suggestion, but for some reason when i hit the button, it opens the main dialog. In the parent dialog i have:

          Value1="test";
          
          CChange change;
          change.DoModal();
          

          then in the child i did:

          CMainDlg maindlg;
          m_edit1.SetWindowText(maindlg.Value1);
          m_edit1.UpdateWindow();	
          

          when i hit the button, it launches the main dialog window as if it were opening the program again ! ? The reason i want this function is so that i can double click an entry in the listctrl and have it open with the strings in edit boxes, so that you can edit them and make changes.

          R Offline
          R Offline
          Renjith Ramachandran
          wrote on last edited by
          #4

          no_life wrote: The reason i want this function is so that i can double click an entry in the listctrl and have it open with the strings in edit boxes, so that you can edit them and make changes. ok..thats your problem is'nt. you can solve that in a better way like this. in your CChange , create a public member variable as m_csEditString and when you double click the list control in the parent dialog, get the currently selected String and call CChange change; change.m_csEditString = "String from parent list"; change.DoModal(); in the CChange class create a control variable for your edit control via ClassWizard let m_edit1 and in the OnInitDialog() function of your CChange class, just call m_edit1.SetWindowText(csEditString ); That will work..!! if you have anymore doubt...feel free to ask me.. I want to change Myself..Can u help me? :)

          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