Thread: Assertion Error with DoModal(), activated from a thread

  1. #1
    Registered User
    Join Date
    Mar 2004

    Assertion Error with DoModal(), activated from a thread

    hi, as with the topic, i am a newbie at MFC programming and ii am having trouble with DoModal
    it shows the window but immediately give an assertion error

    here's how the application init looks like:
    BOOL CAsevApp::InitInstance()
    	time_stop_dlg dlg;
    	m_pMainWnd = &dlg;
    	AfxBeginThread ( th_start_accept, (LPVOID)this );
    	return TRUE;
    over here, time_stop_dlg is a class derived from CDialog, without any changes, but has been linked to IDD_MY_DIALOG_TO_SHOW (as suggested by classwizard)

    this is the thread procedure:
    UINT CAsevApp::th_start_accept( LPVOID lpvParam )
        CAsevApp *th_start_accept = (CAsevApp*)lpvParam;
       return 0;
    process_received_msg(buffer) is a function member of CAsevApp
    void CAsevApp::process_received_msg(char *msg)
    		time_stop_dlg time_stop_dlg_obj;
    		time_stop_dlg_obj.DoModal(); // NIGHTMARE BEGINS HERE!

    a snippet of wincore assertion error:
    BOOL PASCAL CWnd::WalkPreTranslateTree(HWND hWndStop, MSG* pMsg)
    	ASSERT(hWndStop == NULL || ::IsWindow(hWndStop));
    	ASSERT(pMsg != NULL);
    	// walk from the target window up to the hWndStop window checking
    	//  if any window wants to translate this message
    	for (HWND hWnd = pMsg->hwnd; hWnd != NULL; hWnd = ::GetParent(hWnd))
    		CWnd* pWnd = CWnd::FromHandlePermanent(hWnd);
    		if (pWnd != NULL)
    			// target window is a C++ window
    			if (pWnd->PreTranslateMessage(pMsg))
    				return TRUE; // trapped by target window (eg: accelerators)
    		// got to hWndStop window without interest
    		if (hWnd == hWndStop)
    	return FALSE;       // no special processing

    vc6.0 sp6

    your assistance please!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Replies here
    Don't cross-post in future.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to make a thread sleep or std::recv timeout?
    By BrianK in forum Linux Programming
    Replies: 3
    Last Post: 02-26-2003, 10:27 PM
  2. Multithreading
    By Cela in forum Windows Programming
    Replies: 13
    Last Post: 01-15-2003, 03:02 PM
  3. Your Best thread and your most stupid thread ??
    By jawwadalam in forum A Brief History of
    Replies: 13
    Last Post: 01-03-2003, 07:41 PM
  4. MFC Controls and Thread Safety :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 12-06-2002, 11:36 AM
  5. Multi-Thread Programming
    By drdroid in forum C++ Programming
    Replies: 6
    Last Post: 04-04-2002, 02:53 PM