Dialog Box. I am only working on the dll part( I do not have the main
application code).
//Wait for pDlg_Exit_Code. What to do here?
Joseph M. Newcomer wrote:
First, there are serious questions as to why you would want to create a window in a
secondary thread. This usually leads to interesting catastrophes. In particular, the
parent of the window cannot be in the main thread, which your suggestion about creating a
dialog window suggests the dialog has a parent. At this point, you are courting so many
disasters that it isn't funny.
There is rarely a need to put a user-visible window in a secondary thread. You would have
to make a very strong case as to why this made sense. This is not something you consider
doing lightly. Also, it is clear from your question (the answer is obvious: you didn't
create the window!) that you are new at this, and you are boldly going where experienced
MFC programmers see massive signs saying "mine field ahead". Reconsider what you are
doing. If you need to update a window, have a worker thread PostMessage a user-defined
message to the main GUI thread asking it to update whatever needs to be updated. If you
don't want to preempt the main window with a dialog, create a modeless dialog in the main
thread and post the messages to that dialog.
Note that it often makes sense to use a UI thread as a secondary thread for any number of
reasons, but visible user-interface artifacts should not be among them.
joe
On 31 Jul 2006 15:18:25 -0700, "kathy" <yqin_99@yahoo.com> wrote:
I have a Win32 application which call a Dialog based regular MFC dll.
On the dialog box, there is a button which will create a GUI thread:
void CDialog_Dll_Main::OnBnClickedStartThread()
{
// TODO: Add your control notification handler code here
CWinThread* m_pThread =
AfxBeginThread(RUNTIME_CLASS(CMyGUIThread));
}
In the CMyGUIThread::InitInstance():
BOOL CMyGUIThread::InitInstance()
{
// TODO: perform and per-thread initialization here
m_pMainWnd=new CDialog_Thread;
m_pMainWnd->SetForegroundWindow();
m_pMainWnd->ShowWindow(SW_SHOW);
return TRUE;
}
Error here: m_pMainWnd->m_hWnd = 0; which is wrong. But what might
cause this problem?
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm