Update text box i a thread?
I've got a nice little button:
void CTest2Dlg::OnButton1()
{
MyThread newThread(&m_SerialText, &m_SerialTextControl, this);
newThread.CreateNewThread();
}
m_SerialText is a variable connected to an Edit Box.
m_SerialTextControl is a control variable to the Edit box.
In the CreateNewThread I do the following
m_SerialText->Insert(m_SerialText->GetLength(), "nice thread");
m_SerialText->Insert(m_SerialText->GetLength(), "\r\n");
m_SerialTextControl->UpdateWindow();
This does not work exacltly the way I want it to work. The edit box text is not updated until the thread is finished.
I've tried to add m_SerialTextControl->UpdateData(FALSE); but then the program craches.
How do you update a text in an edit box from a thread?
having trouble implementing this thread
Scarlet
I am using you example for a thread that drives a clock for my dialog box. When I try to build my MFC dialog application I get the error for the PostMessage function "Illegal call of non-static member function";
I declared the member function ThreadProc as
static UINT ThreadProc (LPVOID pParam)
and followed the example posted here.
I think the PostMessage function may need to be declared by me, but I thought it was a system defined function. Please straighten me out.
Thanks in advance