Solved

Creating MFC user interface threads

Posted on 2002-04-17
7
262 Views
Last Modified: 2013-11-20
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
Comment
Question by:WarrenW
  • 2
7 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 6947793
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
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 6947834

0
 

Assisted Solution

by:Jedimaster
Jedimaster earned 100 total points
ID: 6967631
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
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11404012
where is my comment ???
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now