How to get Dialog window to show updated value ?
-
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); } }
-
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); } }
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 callm_editnumConnections.SetWindowText()
.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
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 callm_editnumConnections.SetWindowText()
.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
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
-
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
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)