{//read the source file, a a
//reads the data written to the target file
WriteFile. Write (pbufs dwRead);
DwCompleteSize +=dwRead;
PInfo - & gt; M_nSpeed +=dwRead;
//update progress
while(! PInfo - & gt; PUIThread - & gt; PostThreadMessage (WM_THREADINFO, 3, (LPARAM) int ((1.0/dwTotalSize dwCompleteSize *) * 100)))
{
Sleep (10);
}
}
//finish
The delete pbufs.
//close the file
ReadFile. Close ();
WriteFile. Close ();
//end of messages sent to close the progress display module
if (! PInfo - & gt; PUIThread - & gt; PostThreadMessage (WM_THREADINFO, 10, 1))
{
Sleep (10);
}
//pInfo - & gt; KillTimer (1);
//pInfo - & gt; KillTimer (2);
PInfo - & gt; Copying m_stTip. SetWindowText (" done!" );
In a worker thread function and user interface messages sent; The user interface processing function following
//show message processing function
Void CcbCopyFile: : OnThreadInfo (WPARAM WPARAM, LPARAM LPARAM)
{
If (wParam==0)
{//source file path parameter
M_szSrcPath. The Format (" % s ", lParam);
//AfxMessageBox (m_szSrcPath);
}
Else if (wParam==1)
{//target file path parameter
M_szDesPath. The Format (" % s ", lParam);
//AfxMessageBox (m_szDesPath);
}
Else if (wParam==2)
{//start
M_pProgressDlg=new CCopyFileDlg;
M_pProgressDlg - & gt; Create (IDD_DIALOG1);
M_pProgressDlg - & gt; M_szSrcPath=m_szSrcPath;
M_pProgressDlg - & gt; M_szDesPath=m_szDesPath;
M_pProgressDlg - & gt; The UpdateData (FALSE);
M_pProgressDlg - & gt; ShowWindow (TRUE);
}
Else if (wParam==3)
{//progress
M_pProgressDlg - & gt; M_Progress. SetPos (lParam);
}
Else if (wParam==4)
{//speed
M_pProgressDlg - & gt; UpdateSpeed (lParam);
}
Else if (wParam==5)
{//time
LParam float * p=(float *);
M_pProgressDlg - & gt; UpdateTime (* p).
}
The else
{//finish
M_pProgressDlg - & gt; OnCancel ();
}
//return 0;
Problem: when running the user interface thread, drag a window to the user interface,
Progress bar will not be updated; If you don't drag, all operating normally,
Why??????
CodePudding user response:
o Daniel!!!!!!CodePudding user response:
CodePudding user response:
"A simple MFC"