I have a code like this to write install log to a static text and a list control, and i have a button to start the installer that be handle by function OnClickInstallBtn()
but every time I call the WriteLogtoScreen()
, only the static text change and nothing show up in the list until the OnClickInstallBtn()
is done and everything on that list show up all at one.
How can i make it show up right away like the static text?
WriteLogtoScreen(LPCTSTR sLog)
{
int iItems;
iItems = m_ListLog.GetItemCount();
m_ListLog.InsertItem(iItems, sLog);
m_ListLog.Update(iItems);
m_ListLog.SetItemText(iItems, 0, sLog);
m_ListLog.Update(iItems);
UpdateData(FALSE);
SetDlgItemText(IDC_STATIC, sLog);
}
You should call RedrawWindow()
if you want to force the redraw of your list explicitly in something like this :
void WriteLogtoScreen(LPCTSTR sLog)
{
int iItems;
iItems = m_ListLog.GetItemCount();
m_ListLog.InsertItem(iItems, sLog);
m_ListLog.Update(iItems);
m_ListLog.SetItemText(iItems, 0, sLog);
m_ListLog.Update(iItems);
UpdateData(FALSE);
//instant redraw
m_ListLog.RedrawWindow();
SetDlgItemText(IDC_STATIC, sLog);
}