Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Creating MFC user interface threads

Posted on 2002-04-17
7
285 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 163
ORA-01403: no data found 43 106
method notes when mouse over in eclipse 5 87
Problem to Office 1 13
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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

861 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