I have a Dialog-based Application. By default Visual Studio created an App and a Dlg class. I have added buttons, edit boxes, etc. to my dialog. When the user clicks the START button on my dialog it runs a 5 minute automated test and gives text updates and progress in an edit box. Now that this is working great, I would like the user to be able to click on other buttons and check boxes in the dialog while the automated test is running. In order to do this I created a UI thread class using the class wizard called CMyThread. In CMyThread I moved the code that was executed when pressing the START button to the Run() function in CMyThread. I plan on calling the CMyThread Run() function when the START button is clicked. I would still like to get the progress and updates in the dialogs edit box while the 5 minute automated test is running. How do I send a string from CMyThread Run() to the edit box in the dialog and have it display to the user?
Asked
Active
Viewed 378 times
1 Answers
1
It is done by having the MyThread class send messages to be processed by the dialog's message loop.
There are other similar questions on SO with useful answers. How to inform a CDialog Object about a finished task from another thread?
And here's an article with sample code http://forums.codeguru.com/showthread.php?312454-MFC-Thread-How-to-access-UI-elements-from-a-thread-in-MFC

Community
- 1
- 1

Mark Taylor
- 1,843
- 14
- 17
-
Thanks for the sample code. I scrapped the UI thread and tried a worker thread instead. – The rookie Dec 14 '12 at 16:54