Creating MFC user interface threads

I would like to know how to create a user interface thread in MFC. I need to create a Listctrl window in it's own thread. What are the steps to follow using the Winthread class.
Who is Participating?
jkrConnect With a Mentor Commented:
Check the MTMDI sample (should be on your VC++ CD; here's the MSDN link: ("Multithreading: Creating User-Interface Threads") might also be of interest, as well as ("Hide Your Data and Make Objects Responsible for Their Own User Interfaces")

JedimasterConnect With a Mentor Commented:
First create a new class that has the base class CWinThread.

  class CmyThread : public CWinThread

then in the class you want to create it in delare a instance of you CWinThread class:

  CmyThread mythread;

Then where you want to start your GUI thread call:

  myThread = (CDriveThread*) AfxBeginThread(RUNTIME_CLASS(CDriveThread),0,0,0,NULL);

Remember when you want to exit the thread you must call AfxEndThread from inside the thread to correctly end the thread.

Hope that helps.
where is my comment ???
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.