+ Reply to Thread
Results 1 to 3 of 3

Thread: Hot to create User Interface Thread in MFC?

  1. #1

    Hot to create User Interface Thread in MFC?

    Hot to create User Interface Thread in MFC?

    Can you please give me example?

    I want to create a dialog box in another thread which can capture log statement of my application.

    Please help.

  2. #2
    You will need to derive a class from CWinThread MFC class.

    Then you can implement message loop for the derived class.

    You can create new dialog in the YourDerivedClass::InitInstance(...) and call its DoModal.


    class CThreadEx : public CWinThread
    	virtual BOOL InitInstance();
    	virtual int ExitInstance();
    BOOL CThreadEx::InitInstance()
    	// TODO:  perform and per-thread initialization here
    	CThreadDlg objThreadDlg ;
    	m_pMainWnd = &objThreadDlg;
    	int nResponse = objThreadDlg.DoModal();
    	if (nResponse == IDOK)
    	return TRUE;
    void StartUserGUIThread()
            CWinThread *pWinThread = AfxBeginThread(RUNTIME_CLASS(CThreadEx)) ;
    Above code assume that you have implemented CThreadDlg class derived from CDialog.

    Above code will start new thread which host a dialog in it.

    Hope this helps.

  3. #3
    Great help. Thank you.

+ Reply to Thread

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts