SSP
May 21st, 1999, 01:07 AM
In the MFC app(Class Doc,View,Mainframe,App) I have my class A. Class A is a member object of the View class.
classCProcServView: public CListView
{
public:
A m_Process;
}
From the View class, I call a function in class A.
void CProcServView::OnStart()
{
m_Process.StartAllProcesses();
}
In Class A::StartAllProcesses, I create a thread.
BOOL A::StartAllProcesses()
{
CWinThread *pCreateThread;
pCreateThread = AfxBeginThread((AFX_THREADPROC) ProcessKillingThread, (LPVOID)this);
}
Being the thread, I call SendMessage to MFC app. But to do that, I do the following -
DWORD ProcessKillingThread(LPVOID lpDummy)
{
CProcServApp* pApp = (CProcServApp*)AfxGetApp();
CWnd* pWnd = (CWnd*)pApp->m_pMainWnd;
::SendMessage(pWnd->m_hWnd, WM_UPDATELIST, 0,0);
}
But, (CWnd*)pApp->m_pMainWnd shows up as NULL.
Any idea, how to go from here ?
-Thanks,
classCProcServView: public CListView
{
public:
A m_Process;
}
From the View class, I call a function in class A.
void CProcServView::OnStart()
{
m_Process.StartAllProcesses();
}
In Class A::StartAllProcesses, I create a thread.
BOOL A::StartAllProcesses()
{
CWinThread *pCreateThread;
pCreateThread = AfxBeginThread((AFX_THREADPROC) ProcessKillingThread, (LPVOID)this);
}
Being the thread, I call SendMessage to MFC app. But to do that, I do the following -
DWORD ProcessKillingThread(LPVOID lpDummy)
{
CProcServApp* pApp = (CProcServApp*)AfxGetApp();
CWnd* pWnd = (CWnd*)pApp->m_pMainWnd;
::SendMessage(pWnd->m_hWnd, WM_UPDATELIST, 0,0);
}
But, (CWnd*)pApp->m_pMainWnd shows up as NULL.
Any idea, how to go from here ?
-Thanks,