Help. CDialog::DoModal Fail in _beginthreadex 
Author Message
 Help. CDialog::DoModal Fail in _beginthreadex

#include <process.h>

UINT __stdcall thread( void* p )
{
        CDlg dlg;
        dlg.DoModal();
        return 0;

Quote:
}

void CTestThreadDlgDlg::OnButton1()
{
        // TODO: Add your control notification handler code here
        ::AfxBeginThread( (AFX_THREADPROC )thread, NULL, 0, 0, 0, NULL );

Quote:
}

upper code works well.

but

void CTestThreadDlgDlg::OnButton1()
{
        // TODO: Add your control notification handler code here
        _beginthreadex( NULL, 0, thread, 0, 0 , NULL );

Quote:
}

is not work.
but i wnat to call DoModal in _beginthreadex.
how can i do this??
I think there are some MFC thread state init code..

thanks your advance!



Sun, 27 Feb 2005 08:39:41 GMT  
 Help. CDialog::DoModal Fail in _beginthreadex

Quote:

> #include <process.h>

> UINT __stdcall thread( void* p )
> {
>         CDlg dlg;
>         dlg.DoModal();
>         return 0;
> }

> void CTestThreadDlgDlg::OnButton1()
> {
>         // TODO: Add your control notification handler code here
>         ::AfxBeginThread( (AFX_THREADPROC )thread, NULL, 0, 0, 0, NULL );
> }

> upper code works well.

> but

> void CTestThreadDlgDlg::OnButton1()
> {
>         // TODO: Add your control notification handler code here
>         _beginthreadex( NULL, 0, thread, 0, 0 , NULL );
> }

> is not work.
> but i wnat to call DoModal in _beginthreadex.
> how can i do this??
> I think there are some MFC thread state init code..

> thanks your advance!

You are creating a worker thread.  That is a thread that does not pump
windows messages.  Windows/dialogs do not work in a thread that does not
pump messages.  No pump, no GUI.  Rethink your design.

--
Scott McPhillips [VC++ MVP]



Sun, 27 Feb 2005 11:47:49 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Q: CDialog::DoModal () fails

2. Q: CDialog::DoModal fails

3. CDialog::DoModal(), CDialog::EndDialog() Design Flaw

4. HELP! CDialog/DoModal problems in regular DLL

5. HELP: DoModal fails

6. Q: How to move a CDialog before calling DoModal()

7. CDialog::DoModal

8. Using DoModal from CDialog when called from a DLL

9. CDialog.DoModal problem

10. CDialog::DoModal() Behaviour

11. Invalid Page Fault from CDialog.DoModal()

12. Calling CDialog::DoModal crashes

 

 
Powered by phpBB® Forum Software