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. Updating text from another class

Updating text from another class

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialannouncement
7 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.
  • V Offline
    V Offline
    Veeresh Hiremath
    wrote on last edited by
    #1

    Hi all, Can u please tell me how to update an edit-box field present in a model-dialog from another class I have used CUsatDlg *dlg= new CUsatDlg; HWND hdlg =dlg->m_hWnd; SetDlgItemText(hdlg,IDC_SERIALNO,"Serial"); UpdateWindow(hdlg); Where CUsatDlg is mu dialog box class ,and IDC_SERIALNO is my edit box field But the edit-box is not displaying the text

    _ H D T 4 Replies Last reply
    0
    • V Veeresh Hiremath

      Hi all, Can u please tell me how to update an edit-box field present in a model-dialog from another class I have used CUsatDlg *dlg= new CUsatDlg; HWND hdlg =dlg->m_hWnd; SetDlgItemText(hdlg,IDC_SERIALNO,"Serial"); UpdateWindow(hdlg); Where CUsatDlg is mu dialog box class ,and IDC_SERIALNO is my edit box field But the edit-box is not displaying the text

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      Veeresh Hiremath wrote:

      edit-box field present in a model-dialog from another class

      You need to pass a pointer of the class (where the edit box is contained) to another class. Using that pointer you can access the variables in another class.

      Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

      V 1 Reply Last reply
      0
      • _ _AnsHUMAN_

        Veeresh Hiremath wrote:

        edit-box field present in a model-dialog from another class

        You need to pass a pointer of the class (where the edit box is contained) to another class. Using that pointer you can access the variables in another class.

        Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

        V Offline
        V Offline
        Veeresh Hiremath
        wrote on last edited by
        #3

        _AnShUmAn_ I am newbie to vc++/mfc. Can u please send me a skeleton code

        _ 1 Reply Last reply
        0
        • V Veeresh Hiremath

          Hi all, Can u please tell me how to update an edit-box field present in a model-dialog from another class I have used CUsatDlg *dlg= new CUsatDlg; HWND hdlg =dlg->m_hWnd; SetDlgItemText(hdlg,IDC_SERIALNO,"Serial"); UpdateWindow(hdlg); Where CUsatDlg is mu dialog box class ,and IDC_SERIALNO is my edit box field But the edit-box is not displaying the text

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

          if your main class is Main and another class in Local you can use this code on Local class CMain *m_Main=(CMain*)GetParent(); m_Main->functions or variables


          WhiteSky


          1 Reply Last reply
          0
          • V Veeresh Hiremath

            _AnShUmAn_ I am newbie to vc++/mfc. Can u please send me a skeleton code

            _ Offline
            _ Offline
            _AnsHUMAN_
            wrote on last edited by
            #5

            Veeresh Hiremath wrote: Can u please send me a skeleton code Here is a sample code. You access the function of class B from class A. On similar lines you can also use the variables etc. #include using namespace std; class B { public: B() { cout<<"Constructor of B\n"; } void Display() { cout<<"In Function Display of B\n"; } }; class A { public: B b; A() { cout<<"Constructor of A\n"; } void CallBClassFn() { b.Display(); } }; int _tmain(int argc, _TCHAR* argv[]) { A a; a.CallBClassFn (); return 0; } I hope this helps in solving out your problem... Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

            1 Reply Last reply
            0
            • V Veeresh Hiremath

              Hi all, Can u please tell me how to update an edit-box field present in a model-dialog from another class I have used CUsatDlg *dlg= new CUsatDlg; HWND hdlg =dlg->m_hWnd; SetDlgItemText(hdlg,IDC_SERIALNO,"Serial"); UpdateWindow(hdlg); Where CUsatDlg is mu dialog box class ,and IDC_SERIALNO is my edit box field But the edit-box is not displaying the text

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

              Simply post a message to the window (e.g., dialog) that owns the edit control.


              "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

              "Judge not by the eye but by the heart." - Native American Proverb

              1 Reply Last reply
              0
              • V Veeresh Hiremath

                Hi all, Can u please tell me how to update an edit-box field present in a model-dialog from another class I have used CUsatDlg *dlg= new CUsatDlg; HWND hdlg =dlg->m_hWnd; SetDlgItemText(hdlg,IDC_SERIALNO,"Serial"); UpdateWindow(hdlg); Where CUsatDlg is mu dialog box class ,and IDC_SERIALNO is my edit box field But the edit-box is not displaying the text

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #7

                Veeresh Hiremath wrote:

                CUsatDlg *dlg= new CUsatDlg; HWND hdlg =dlg->m_hWnd;

                you need the actual Window Handle of displayed window.. this willnot help.. either have a pointer to that class. or make some global variable!

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                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