我用thread=AfxBeginThread(RUNTIME_CLASS(CMyThread),0,0,0,0);
启动了一个线程,现在,在CMyThread类里面有个函数CMyThread::setButton(CButton *p);用来把对话框类的一个成员变量CButton m_button的地址传到CMyThread类里面,请问怎么做。
又不能定义CMyThread类的对象,请问大家怎么办?
启动了一个线程,现在,在CMyThread类里面有个函数CMyThread::setButton(CButton *p);用来把对话框类的一个成员变量CButton m_button的地址传到CMyThread类里面,请问怎么做。
又不能定义CMyThread类的对象,请问大家怎么办?
thread=AfxBeginThread(RUNTIME_CLASS(CMyThread),0,0,0,0);
中的thread就是CMyThread类的对象啊.你可以直接在外部定义一个类对象指针: CMyThread * mythread=(CMyThread *)thread;
然后用:
mythread->SetButton(&m_button); 即可传进去了.
线程就已经启动了,