K.M. Shihab Uddin
K.M. Shihab Uddin

Reputation: 90

How to set mfc c++ editbox repeatedly?

I selected multiple files from desktop.

CFileDialog fileDlg(TRUE, 
                    _T("*.txt"), 
                    NULL, 
                    OFN_ALLOWMULTISELECT, 
                    _T(" (*.txt)|*.txt|"));

fileDlg.DoModal();
POSITION pos(fileDlg.GetStartPosition());

while (pos)
{
    CString pathName1(fileDlg.GetNextPathName(pos));
    SetDlgItemText(IDC_EDITReference, pathName1);
    Sleep(2.0 * 1000);
}

It's very simple code which should show the file paths after every 2 seconds. If I select 10 files, it waits for 20 seconds, then show only the path of the last file selected. It doesn't update after every 2 seconds.

Could someone help me with this??

Upvotes: 0

Views: 92

Answers (1)

Your function is (slowly) changing the text in the dialog item - but the dialog doesn't get repainted until your function exits. You need to cal UpdateWindow after the call to SetDlgItemText

Upvotes: 1

Related Questions