强制更新列表框 我用MFC使用C++,并且我有一个ListBox绑定到一个变量,我在运行时更新了: void CFileSelection::OnBnClickedFiletousb() { m_LogC.AddString(_T("Starting move to USB, Please Wait...")); UpdateData(FALSE); // Code to move files from disk to USB m_LogC.AddString(_T("Move to USB Successful.")); }
但是,尽管有UpdateData,ListBox在完成任务之前不会填充任何字符串。是否有办法使其在执行其余代码之前更新屏幕?更改列表框上的文本后使用此功能。您的问题是其他调用正在阻止MessageThread,但是您可以使用它强制更新强制更新列表框 我用MFC使用C++,并且我有一个ListBox绑定到一个变量,我在运行时更新了: void CFileSelection::OnBnClickedFiletousb() { m_LogC.AddString(_T("Starting move to USB, Please Wait...")); UpdateData(FALSE); // Code to move files from disk to USB m_LogC.AddString(_T("Move to USB Successful.")); },c++,user-interface,listbox,C++,User Interface,Listbox,但是,尽管有UpdateData,ListBox在完成任务之前不会填充任何字符串。是否有办法使其在执行其余代码之前更新屏幕?更改列表框上的文本后使用此功能。您的问题是其他调用正在阻止MessageThread,但是您可以使用它强制更新 void ProcessWindowMessages() { MSG msg; while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) // let them see the message
void ProcessWindowMessages()
{
MSG msg;
while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) // let them see the message before we go into longer term wait
{
TranslateMessage(&msg); // translate it
DispatchMessage(&msg); // and let windows dispatch it to WinProc
}
}
或者你也可以打电话
yourlistboxVariable->UpdateWindow();