I need to make a thread using AfxBeginThread in a MFC application that uses some dialog boxes, but because the thread function is inside a class I have to make it static, and then I can’t use any controls because they are not static, and even if I make them static I get some linker errors.
Can someone tell me how its the correct way to implement this ? Do i really need to declar the controls static ? Or is there any other way to do this ?
This are the errors (without static)
error C2228: left of '.AddString' must have class/struct/union
With static:
unresolved external symbol "public: static class CListBox CsearchDlg::m_musicList" (?m_musicList@CsearchDlg@@2VCListBox@@A)
The thread function is supposed to receive a parameter that you pass to
AfxBeginThreadaspParam, and you can pass there the pointer to your class, and from the thread function call whatever class member function you want. That’s how I do it.Something like this (pseudo code):