(MFC) CStatusBar thread calls the collapse problem
Time:09-22
I had a solution, for the sake of convenience in each dialog box (Child) Style: call the CStatusBar, I defined it in the App files (CStatusBar m_statusBar), I first in the main dialog to m_statusBar do initialization operation, no problem, but when I was a child in the dialog box thread (I need in this thread to manipulate) the m_statusBar call but collapsed,
Followed by the code:
//thread information structure of the definition of Struct struct_MyInfo { . StatusBar CStatusBar *; };
. TheApp. M_statusBar. SetPaneText (0, L "is for version information... ");//& lt; Here - nothing Struct_MyInfo * p=new struct_MyInfo; . p-> StatusBar=& amp; (theApp m_statusBar);//& lt; - m_statusBar I is defined in the App CWinThread * pThread=AfxBeginThread (MyThread (LPVOID), p); .
return TRUE;//return TRUE unless you set the focus to a control //exception: OCX property page should return FALSE }
//threadUINT MyThread (LPVOID lpParam) { LpParam struct_MyInfo * p=(struct_MyInfo *); . p-> StatusBar - & gt; SetPaneText (0, L "ready");//& lt; - this will collapse return 0; }
CodePudding user response:
I try to use in the thread main dialog pointer SetTimer (... ), and then the OnTimer (... ) m_statusBar can operation
CodePudding user response:
To set breakpoints, and see if the pointer is normal, whether the call stack with other information Struct_MyInfo * p=new struct_MyInfo; Suggested that the p as a class variable, otherwise when the delete bad management