15,471
社区成员
发帖
与我相关
我的任务
分享
// 声明
static void threadfunc(LPVOID lParam);
// 实现
void threadfunc(LPVOID lParam)
{
}
// 线程函数声明:在主窗口类的头文件里
static void threadfunc(LPARAM lParam);
// 创建线程:
DWORD dwThreadID;
CreateThread(NULL, NULL, &threadfunc, this, 0, &dwThreadID);
OnYourMessage(WPARAM wParam, LPARAM lParam)
{
int ndata = (int)lParam;
// 这里就可以用ndata 接收到的数据去更新进度条了
}
void threadfunc(LPARAM lParam)
{
// 线程函数里面: CMainWnd是主窗口类
CMainWnd *pwnd = (CMainWnd *)lParam;
// ndata 是要传给主窗口类的数据,比如说进度等等
int ndata = 1;
PostMessage(pwnd->GetSafeHwnd(), YOURMESSAGE, 0, (LPARAM)ndata);
}