晕,一楼在说什么啊? 请参阅MSDN There are two general types of threads that CWinThread supports: worker threads and user-interface threads. Worker threads have no message pump: for example, a thread that performs background calculations in a spreadsheet application. User-interface threads have a message pump and process messages received from the system. CWinApp and classes derived from it are examples of user-interface threads. Other user-interface threads can also be derived directly from CWinThread.
ON_THREAD_MESSAGE 映射线程消息
请参阅MSDN
There are two general types of threads that CWinThread supports: worker threads and user-interface threads. Worker threads have no message pump: for example, a thread that performs background calculations in a spreadsheet application. User-interface threads have a message pump and process messages received from the system. CWinApp and classes derived from it are examples of user-interface threads. Other user-interface threads can also be derived directly from CWinThread.
{
//从数据采集卡中读取数据:
ReadDataFromHardware();
//在界面edit中显示数据:
SetDlgItem(IDC_EDIT1, sData); //这句话放在工作线程中行不行?
}
SetDlgItem函数是CDialog的方法,怎么能调用呢?
可以在Work线程创建时将Dialog的指针传给线程,再从线程中还原出来调用Dialog的方法,
不过这种方法也不好。
hDlg唯控件所在窗口句柄,IDC_VALUE_SET唯控件ID,str為設置的字符串。在任何地方調用都可以。
用来处理用户消息的。
然后UI线程或者主线程不必去管WORK线程如何,只管显示缓冲区的数据.