同上
请给出::AfxBeginThread的具体例子以及如何在县城中调用
SetPaneText函数的
定义一个全局变量:
LPVOID p;
在对话框的类里边儿:
p=this;
在全局的地方:
extern LPVOID p;
在其它类的里边儿:
C***Dlg * dlg=static_cast<C***Dlg *>(p);
CStatusBar* pStauts;
pStatus=(CStatusBar*)
dlg->AfxGetApp()->m_pMainWnd->GetDescendantWindow(AFX_IDW_STATUS_BAR);
pStatus->SetPaneInfo(1,ID_SEPARATOR,SBPS_STRETCH,700);
pStatus->SetPaneText(0,"asdf");
pStatus->SetPaneText(1,"就绪");
Pay attention to "CWnd::AssertValid()". Following note cut from it.
// Note: if either of the above asserts fire and you are
// writing a multithreaded application, it is likely that
// you have passed a C++ object from one thread to another
// and have used that object in a way that was not intended.
// (only simple inline wrapper functions should be used)
//
// In general, CWnd objects should be passed by HWND from
// one thread to another. The receiving thread can wrap
// the HWND with a CWnd object by using CWnd::FromHandle.
//
// It is dangerous to pass C++ objects from one thread to
// another, unless the objects are designed to be used in
// such a manner.
其实你把状态栏窗口的hwnd,传入线程,然后SendMessage()
也可以把状态栏类的地址传进线程,然后引用一下就行了。
同意楼上:
消息驱动的系统,要多用消息:)
通常的做法应该为:向线程传送主窗口的句柄
由线程向主窗口发送消息
主窗口中用一个一致的方法更新状态条的控件
我也建议你用消息来完成!
比较安全!比较简单!