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):
NowyoucanusepViewinMyClassinsteadof((CMDIFrameWnd*)AfxGetMainWnd()->GetActiveWindow()).
------------------------
Answerfromcodeguru(cy163)
Thethreadbelowanswersyourdilemma:
HowtoaccessUIelementsfromathreadinMFC?
http://www.codeguru.com/forum/showthread.php?t=312454
JististopasstheHWNDofthewindowyouneedtoupdatetothethreadinsomewayandusetheHWND(andNOTCWndobjectpointer)
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:
JististopasstheHWNDofthewindowyouneedtoupdatetothethreadinsomewayandusetheHWND(andNOTCWndobjectpointer)
相关文章推荐
- How to pass ViewState value from web form page to web user control page?
- How to popup a UIPickerView from the bottom of a UIScrollView in response to UITextField selection
- How to access a value defined in the application.properties file in Spring Boot ( Externalized Conf)
- WinForms Controls > Examples > How to: Add New XtraForm, RibbonForm and XtraUserControl to Your Proj
- [XAF] How to define a business class at runtime or allow end-users to configure its members via the application UI?
- How to add MFC Common class into your application based on SDK?
- How to access Master page controls from the Content page
- How to stop UITableView from clipping UITableViewCell contents in iOS 7
- How to resolve "your security settings have blocked an untrusted application from running" in Mac
- Binding UI Events from View to commands in ViewModel in Silverlight 4(转)
- Could not create the view: Plug-in org.eclipse.jdt.ui was unable to load class org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart
- HowTo access metadata from RDO Havana Instance on Fedora 20 & OpenStack Networking concepts
- How to get UITableView from UITableViewCell?
- How to set user-defined-type as Oracle SP input parameter in .NET
- mysql how to fix Access denied for user 'root'@'localhost'
- Assigning to 'AppDelegate *' from incompatible type 'id<UIApplicationDelegate>'
- user master page with asp:FormParameter , save only blank data to Database MSAccess
- How to pass selected records from form to dilog in AX 2012
- How To Implement Forms-Based Authentication in Your ASP.NET Application by Using C# .NET
- [c#] How to use Data Access Application Block?