[Q] Updating an control inside other control handler problem...
-
Hello, Setting the edit box text via SetWindowText does not work inmediatelly if you set it from one of the handlers of your dialog. Instead, the update will happen only after the handler ends its run.
void CDemoDlg::OnNewBnClicked()
{
m_newBtn.EnableWindow(FALSE);
GetDlgItem(IDC_STATUS_EDIT)->SetWindowText("New"); // Change here to IDC_STATUS_STATIC
...
// Some code that takes few msec to end
...
m_newBtn.EnableWindow(TRUE);
}If I replace the Edit Control with a static control, the text is updated inmediatelly. (Before the button control is enabled) I guess that the answer is the use of SendMessage and PostMessage. Is there a way to update an edit control inmediatelly and not wait till the handler ends? Any hint? (I need an edit control there) Another example:
void CDemoDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
HWND hwnd = pScrollBar->GetSafeHwnd();
if (hwnd == m_mainCursorSliderCtrl.GetSafeHwnd())
{
int pos = m_mainCursorSliderCtrl.GetPos();
if (pos != m_mainCursorPosition)
{
CString text;
m_mainCursorPosition = pos;
text.Format("Main:%d", pos)
GetDlgItem(IDC_STATUS_EDIT)->SetWindowText(text);
GetDlgItem(IDC_STATUS_STATIC)->SetWindowText(text);
UpdateListControlData();
}
}} CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
The list control and
IDC_STATUS_EDIT
is update only when the slider-bar stops, while theIDC_STATUS_STATIC
is updated on real-time.-- **Ricky Marek** (_AKA: rbid_)
-- "Things are only impossible until they are not" --- Jean-Luc Picard My articles