Re: Thread and TabControl problem
I read your essay page on Worker Threads and wrote the following program
segment based on the section "The Thread Solution" where the thread is moved
from C Static domain to the MFC domain. And I am not exactly sure if it is
written correctly since I needed to pass the main dialog pointer to the
non-static thread function. There is a non-window ActiveX program used in
the thread and it has to have a pointer to the main dialog. Have I correctly
written the cast and function call for the non-static thread function? I
tried using a & before the variable pDlg argument in the call but it caused
a compiler error.
void CDemoDlg::OnStart() //start button
{
AfxBeginThread(StarterThread1, this);
}
UINT CDemoDlg::StarterThread1(LPVOID lParam)
{
CDemoDlg *pDlg = static_cast<CDemoDlg *>(lParam);
pDlg->Thread1(pDlg); //call for the non-static thread function
return 0;
}
void CDemoDlg::Thread1(CDemoDlg *pDlg)
{
pDlg->m_xActiveX.Open();
"other statements"
pDlg->m_xActiveX.Close();
}