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. How to get Dialog window to show updated value ?

How to get Dialog window to show updated value ?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionannouncement
4 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.
  • G Offline
    G Offline
    glweid
    wrote on last edited by
    #1

    I have a derived Dialog class - CGeneralStatus that has a CString variable. If I set the string before I create the CGeneralStatus dialog it is displayed OK. When I set this string to different value the value in the window does not get changed. Even if I close and reopen the dialog window the value does not change. Any input is greatly appreciated ! ------------------------------------------------------------------------ Application code: void CFV3TaskMonApp::OnGeneralstatus() { if(IsShowingGeneral()) { HideGeneral(); } else { ShowGeneral(m_pMainWnd->GetActiveWindow()); } } void CFV3TaskMonApp::ShowGeneral(CWnd* parent) { if (!::IsWindow(*m_generalStatus)) { m_generalStatus->Create(IDD_GeneralStatus, parent); } m_generalStatus->GeneralChanged(); // update the string m_generalStatus->ShowWindow(1); } Code snippet to update the string value before calling ShowWindow(1): void CGeneralStatus::GeneralChanged() { CString out; out.Format("%d",m_app->m_numConnections); m_connAttempts = out; if (::IsWindow(this->GetSafeHwnd())) { ::PostMessage(this->GetSafeHwnd(),UWM_STATUS_UPDATEGENERAL,0,0); } }

    D 1 Reply Last reply
    0
    • G glweid

      I have a derived Dialog class - CGeneralStatus that has a CString variable. If I set the string before I create the CGeneralStatus dialog it is displayed OK. When I set this string to different value the value in the window does not get changed. Even if I close and reopen the dialog window the value does not change. Any input is greatly appreciated ! ------------------------------------------------------------------------ Application code: void CFV3TaskMonApp::OnGeneralstatus() { if(IsShowingGeneral()) { HideGeneral(); } else { ShowGeneral(m_pMainWnd->GetActiveWindow()); } } void CFV3TaskMonApp::ShowGeneral(CWnd* parent) { if (!::IsWindow(*m_generalStatus)) { m_generalStatus->Create(IDD_GeneralStatus, parent); } m_generalStatus->GeneralChanged(); // update the string m_generalStatus->ShowWindow(1); } Code snippet to update the string value before calling ShowWindow(1): void CGeneralStatus::GeneralChanged() { CString out; out.Format("%d",m_app->m_numConnections); m_connAttempts = out; if (::IsWindow(this->GetSafeHwnd())) { ::PostMessage(this->GetSafeHwnd(),UWM_STATUS_UPDATEGENERAL,0,0); } }

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

      glweid wrote: When I set this string to different value the value in the window does not get changed. Even though you've assigned a value to a CString variable, you did not indicate how it was being displayed. Assuming it was an edit or static control, you simply need an appropriate control variable in the dialog's declaration (e.g., CEdit m_editnumConnections). When it comes time to display the value, simply call m_editnumConnections.SetWindowText().


      "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

      A 1 Reply Last reply
      0
      • D David Crow

        glweid wrote: When I set this string to different value the value in the window does not get changed. Even though you've assigned a value to a CString variable, you did not indicate how it was being displayed. Assuming it was an edit or static control, you simply need an appropriate control variable in the dialog's declaration (e.g., CEdit m_editnumConnections). When it comes time to display the value, simply call m_editnumConnections.SetWindowText().


        "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        My Dialog box only has the string variable (edit control - read only) box displayed, how do you declare a CEdit variable associated with that ? I added a CEdit m_editnumCOnnections compiled it and passed the new string value to m_editnumConnections.SetWindowText() and it cores not finding a main window handle. Thanks ! ----------- Code snip // Dialog Data //{{AFX_DATA(GeneralStatus) enum { IDD = IDD_GeneralStatus }; CString m_connAttempts; //}}AFX_DATA

        D 1 Reply Last reply
        0
        • A Anonymous

          My Dialog box only has the string variable (edit control - read only) box displayed, how do you declare a CEdit variable associated with that ? I added a CEdit m_editnumCOnnections compiled it and passed the new string value to m_editnumConnections.SetWindowText() and it cores not finding a main window handle. Thanks ! ----------- Code snip // Dialog Data //{{AFX_DATA(GeneralStatus) enum { IDD = IDD_GeneralStatus }; CString m_connAttempts; //}}AFX_DATA

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

          Anonymous wrote: how do you declare a CEdit variable associated with that ? ClassWizard. Anonymous wrote: ...and it cores not finding a main window handle What does "cores" mean in this context? Did you add the appropriate entry to DoDataExchange()? This is something that ClassWizard would do for you.


          "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

          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