Update dialog box from thread outside class



I need to access a dialog box from a thread outside of the dialog box class.

in portai.cpp, the thread is called like this:
m_pReaderThread = AfxBeginThread(ReaderThread, (LPVOID)this);

m_pReaderThread is declared like this in portai.h  CWinThread* m_pReaderThread;      
and the thread is declared as UINT CiPortAI::ReaderThread(LPVOID pThis)

I want to be able to update text boxes on my main dialog box from within the thread. How do I do this?
apostrophe27Asked:
Who is Participating?
 
alb66Connect With a Mentor Commented:
I think the best solution is to pass the handle of the dialog to the thread. Then you can post some application defined message to the dialog in order to update the user interface.

http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=435
http://vcfaq.mvps.org/mfc/12.htm
0
 
vachoohoCommented:
cast LPVOID pThis to the class from which it was called ()pThis
0
 
apostrophe27Author Commented:
Excellent!

It worked, and I learned about worker threads. Thanks.
0
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.