Click here to Skip to main content
15,908,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my codes are following:
C++
DWORD WINAPI ThreadProc(LPVOID lpParemeter)
{
   CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
   CView *myview = (CView*)pFrame->GetActiveFrame()->GetActiveView();
}
//where  ThreadProc is a thread function.

Why not get the pointer of the view?

I also found the GetParent() is invalid. In other words, in the thread function, I can't call the GetParent() to get the pointer of the dialog' parent window.

Thus, GetParent(),GetActiveFrame(),GetActiveView() are invalid in the thread function.

How to do?
Help me,Thank you!
Posted
Updated 30-Nov-10 1:00am
v2

The easiest way to solve this would be to pass the pointer of the view directly as argument when creating the thread.

LPVOID lpParemeter would then contain the wanted pointer.
 
Share this answer
 
// How to do?

Try to find the way
to notify the windows about your wished actions
by the posting (WM_USER + X) messages to them.

In other words,
the secondary threads should try
to say something (to do) to the windows created in other threads
(and not try to ask something them) :)

Do you know why are you needing a view ?
So you could just order an action based on this reason.
 
Share this answer
 
It is correct to say that GetParent(),GetActiveFrame(),GetActiveView() are invalid in the thread function. You need to invoke this into the main thread.

http://blogs.msdn.com/b/csharpfaq/archive/2004/03/17/91685.aspx[^]

Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900