您的位置:首页 > 移动开发

How to access UI controls from a user defined class (CFormView based SDI application)

2006-11-05 20:09 441 查看
Answersfromcodeproject(cy163cy163)

GetActiveWindow()isthread-specific.Youhavenoactivewindowsinyourworkerthread.

WhynotaddaCHhhhView*membertoyourMyClassclass(passitinintheconstructor):


classMyClass
{
CHhhhView*pView;
public:
MyClass(CHhhhView*view){pView=view;}
};

voidCHhhhView::OnButton1()
{
//TODO:Addyourcontrolnotificationhandlercodehere
MyClass*objMyClass=newMyClass(this);
AfxBeginThread(MyThreadProc,objMyClass);
}


NowyoucanusepViewinMyClassinsteadof((CMDIFrameWnd*)AfxGetMainWnd()->GetActiveWindow()).

------------------------
Answerfromcodeguru(cy163)

Thethreadbelowanswersyourdilemma:
HowtoaccessUIelementsfromathreadinMFC?
http://www.codeguru.com/forum/showthread.php?t=312454
JististopasstheHWNDofthewindowyouneedtoupdatetothethreadinsomewayandusetheHWND(andNOTCWndobjectpointer)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐