• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

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.
0
WarrenW
Asked:
WarrenW
  • 2
2 Solutions
 
jkrCommented:
Check the MTMDI sample (should be on your VC++ CD; here's the MSDN link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/html/_sample_mfc_mtmdi.asp)

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_Multithreading.3a_.Creating_User.2d.Interface_Threads.asp ("Multithreading: Creating User-Interface Threads") might also be of interest, as well as http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0197/formsp3/formsp3.htm&nav=/msj/0197/newnav.htm ("Hide Your Data and Make Objects Responsible for Their Own User Interfaces")
0
 
sudhakar_koundinyaCommented:

0
 
JedimasterCommented:
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.
0
 
sudhakar_koundinyaCommented:
where is my comment ???
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now