初次发帖还没分,大哥们帮帮忙1.我有一个耗时比较长的函数,我想在搜索线程正式运行前使用SetWindowText在一个编辑框中显示提示信息。但是每次点击开始后编辑框信息不会马上更新,而是等到Search_Count(m_strDir,sztxtpath)运行完成,子线程开始执行并向主线程发送消息时界面才刷新。
2.如果编辑框换成静态文本标签,SetWindowText则能马上更新界面能告诉我是什么原因吗?部分代码如下void CDirReaderDlg::OnBtnReadg()
{
// TODO: Add your control notification handler code here
ct0=CTime::GetCurrentTime();
GetDlgItem(IDC_EDIT_NOTIC)->SetWindowText("读盘中.....");
////////路径设置,文件名设置 /////////文件计数
Search_Count(m_strDir,sztxtpath);////耗时长
/////////开始详细文件统计
m_pSearchTheard=(SearchTheard*)AfxBeginThread(RUNTIME_CLASS(SearchTheard)); m_pSearchTheard->PostThreadMessage(WM_SEARCH,LONG(&sp),m_iMax);
return ;}
2.如果编辑框换成静态文本标签,SetWindowText则能马上更新界面能告诉我是什么原因吗?部分代码如下void CDirReaderDlg::OnBtnReadg()
{
// TODO: Add your control notification handler code here
ct0=CTime::GetCurrentTime();
GetDlgItem(IDC_EDIT_NOTIC)->SetWindowText("读盘中.....");
////////路径设置,文件名设置 /////////文件计数
Search_Count(m_strDir,sztxtpath);////耗时长
/////////开始详细文件统计
m_pSearchTheard=(SearchTheard*)AfxBeginThread(RUNTIME_CLASS(SearchTheard)); m_pSearchTheard->PostThreadMessage(WM_SEARCH,LONG(&sp),m_iMax);
return ;}
"If the target window is owned by the current process, SetWindowText causes a WM_SETTEXT message to be sent to the specified window or control. If the control is a list box control created with the WS_CAPTION style, however, SetWindowText sets the text for the control, not for the list box entries.
To set the text of a control in another process, send the WM_SETTEXT message directly instead of calling SetWindowText.
The SetWindowText function does not expand tab characters (ASCII code 0x09). Tab characters are displayed as vertical bar (|) characters. ”
可能需要用SendMessage(WM_SETTEXT);
UpdateWindow(); // 强制窗口立刻刷新