Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate a dialog in UI Thread causes crash
    primarykey
    data
    text
    <p>I tried to create a dialog in a UI thread(CWinThread). However, it crashes when the CDialog::Create() is called. I had verified with previous implementation, the dialog is successfully created in non-threading mode.</p> <p>Does any guru here know the crash reason of creating a dialog in CWinThread?</p> <p>Without Threading:</p> <pre><code>class CProduction : public CDialog{ ... } class CScrollProductionView : public CScrollView{ CProduction *m_pProduction; ... } void CScrollProductionView::OnInitialUpdate(){ m_pProduction = new CProduction(0, *m_pVisionAdapter); m_pProduction-&gt;Create(IDD_DLG_PROD, this); //--&gt; created dialog successfully m_pProduction-&gt;ShowWindow(SW_SHOW); } </code></pre> <p>Implement UI Thread:</p> <pre><code>class CProduction : public CDialog{ ... } class CScrollProductionView : public CScrollView{ CProductionThread* m_pProdThread; ... } class CProductionThread : public CWinThread{ CProduction *m_pProduction; ... } void CScrollProductionView::OnInitialUpdate(){ m_pProdThread-&gt;PostThreadMessage(WM_INITPRODTHREADMESSAGE, PROD_INIT, (LPARAM)m_pVisionAdapter); m_pProdThread-&gt;PostThreadMessage(WM_INITPRODTHREADMESSAGE, PROD_CREATE_DLG, (LPARAM)this); } void CProductionThread::InitMessageHandler(WPARAM wParam, LPARAM lParam) { printf("Receiving InitMessageHandler msg %d\n", (UINT)wParam); switch(wParam) { case PROD_INIT: { CVisionAdapter* pAdapter = (CVisionAdapter*)lParam; m_pProduction = new CProduction(NULL, *pAdapter); } break; case PROD_CREATE_DLG: { CScrollProductionView* pView = (CScrollProductionView*)lParam; m_pProduction-&gt;Create(IDD_DLG_PROD, pView); //--&gt; Crash here m_pProduction-&gt;ShowWindow(SW_SHOW); } break; default: break; } } </code></pre> <p>Error message: </p> <blockquote> <p>Debug Assertion Failed! ..<br> File: .... wincore.cpp<br> Line: 9906</p> </blockquote> <p>Thanks you for viewing this question.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload