Assertion Error with DoModal(), activated from a thread

This is a discussion on Assertion Error with DoModal(), activated from a thread within the Windows Programming forums, part of the Platform Specific Boards category; hi, as with the topic, i am a newbie at MFC programming and ii am having trouble with DoModal it ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    114

    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

    http://img186.imageshack.us/img186/9563/assert9dk.jpg

    here's how the application init looks like:
    Code:
    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:
    Code:
    UINT CAsevApp::th_start_accept( LPVOID lpvParam )
    {
        CAsevApp *th_start_accept = (CAsevApp*)lpvParam;
        th_start_accept->process_received_msg(buffer);
       return 0;
    }
    process_received_msg(buffer) is a function member of CAsevApp
    Code:
    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:
    Code:
    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)
    			break;
    	}
    	return FALSE;       // no special processing
    }
    http://img186.imageshack.us/img186/7370/retrn0wk.jpg

    using
    vc6.0 sp6

    your assistance please!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    Replies here
    Assertion Error with DoModal(), activated from a thread
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 09:27 PM
  2. Multithreading
    By Cela in forum Windows Programming
    Replies: 13
    Last Post: 01-15-2003, 02:02 PM
  3. Your Best thread and your most stupid thread ??
    By jawwadalam in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 01-03-2003, 06:41 PM
  4. MFC Controls and Thread Safety :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 12-06-2002, 10:36 AM
  5. Multi-Thread Programming
    By drdroid in forum C++ Programming
    Replies: 6
    Last Post: 04-04-2002, 01:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21