Threads & CPropertySheet
-
Hello I have problems with adding a property page in a new thread. The problem is CPropertyPage::AddPage() always produces debug assertion failure, when running from a thread. it looks like this: UINT SomeThread(LPVOID p) { ... CMyPropertyPage* newpage; newpage=new CMyPropertyPage; pdlg->m_PropertySheet.AddPage(newpage); //debug asertion failed ... } pdlg in this example was restored from the FromHandle function. I know that this error is caused by the fact that AddPage() is run in separate thread. Anyone knows how to do it properly ? I will appreciate any suggestions... thanks
-
Hello I have problems with adding a property page in a new thread. The problem is CPropertyPage::AddPage() always produces debug assertion failure, when running from a thread. it looks like this: UINT SomeThread(LPVOID p) { ... CMyPropertyPage* newpage; newpage=new CMyPropertyPage; pdlg->m_PropertySheet.AddPage(newpage); //debug asertion failed ... } pdlg in this example was restored from the FromHandle function. I know that this error is caused by the fact that AddPage() is run in separate thread. Anyone knows how to do it properly ? I will appreciate any suggestions... thanks
Post a message to the original thread to add the page. (PostThreadMessage) Good Luck, Bill
-
Post a message to the original thread to add the page. (PostThreadMessage) Good Luck, Bill
-
Thanks for the reply... ..but the thread in which CPropertySheet was created is the main user interface thread... and I don't know how to send it a ThreadMessage... Is there any other solution ?
Ok, Problem : Cannot get window handle to CPropertySheet Solution : No problem, all we need is the thread handle and we can post a msg to it. Analysis : Ok, every MFC project contains the global CWinApp derived object. Use that to get the handle of the main thread, and do a PostThreadMessage. MFC takes care of the routing, so dont worry. Just make sure that the id of the msg is unique and there is a handle in the CProp(Page)(Sheet) you want to handle the message.