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

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?
0
apostrophe27
Asked:
apostrophe27
1 Solution
 
vachoohoCommented:
cast LPVOID pThis to the class from which it was called ()pThis
0
 
alb66Commented:
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
 
apostrophe27Author Commented:
Excellent!

It worked, and I learned about worker threads. Thanks.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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