我有一个对话框在执行到CDialog::domodal()函数的时候,没什么异常发生的就给我把对话框给销毁了。
TRY
{
// create modeless dialog
AfxHookWindowCreate(this);
if (CreateDlgIndirect(lpDialogTemplate,
CWnd::FromHandle(hWndParent), hInst))
{
if (m_nFlags & WF_CONTINUEMODAL)
{
// enter modal loop
DWORD dwFlags = MLF_SHOWONIDLE;
if (GetStyle() & DS_NOIDLEMSG)
dwFlags |= MLF_NOIDLEMSG;
VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
} // hide the window before enabling the parent, etc.
if (m_hWnd != NULL)
SetWindowPos(NULL, 0, 0, 0, 0, SWP_HIDEWINDOW|
SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
}
}
CATCH_ALL(e)
{
DELETE_EXCEPTION(e);
m_nModalResult = -1;
}
END_CATCH_ALL if (bEnableParent)
::EnableWindow(hWndParent, TRUE);
if (hWndParent != NULL && ::GetActiveWindow() == m_hWnd)
::SetActiveWindow(hWndParent); // destroy modal window
DestroyWindow(); //代码能一路顺利的执行到这里,按说是应该在前面的某处阻塞的
PostModal();请问一般问题应该是出现在哪里??
TRY
{
// create modeless dialog
AfxHookWindowCreate(this);
if (CreateDlgIndirect(lpDialogTemplate,
CWnd::FromHandle(hWndParent), hInst))
{
if (m_nFlags & WF_CONTINUEMODAL)
{
// enter modal loop
DWORD dwFlags = MLF_SHOWONIDLE;
if (GetStyle() & DS_NOIDLEMSG)
dwFlags |= MLF_NOIDLEMSG;
VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
} // hide the window before enabling the parent, etc.
if (m_hWnd != NULL)
SetWindowPos(NULL, 0, 0, 0, 0, SWP_HIDEWINDOW|
SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
}
}
CATCH_ALL(e)
{
DELETE_EXCEPTION(e);
m_nModalResult = -1;
}
END_CATCH_ALL if (bEnableParent)
::EnableWindow(hWndParent, TRUE);
if (hWndParent != NULL && ::GetActiveWindow() == m_hWnd)
::SetActiveWindow(hWndParent); // destroy modal window
DestroyWindow(); //代码能一路顺利的执行到这里,按说是应该在前面的某处阻塞的
PostModal();请问一般问题应该是出现在哪里??
解决方案 »
- 急寻求助啊,使用Visual Studio 2008时,属性窗口的一些功能按钮突然不见了,怎么办?!
- 设计模式-Factory的意义,不能清楚地理解它?
- select 列时,有group by,有的列无法选取怎么办?
- int nSizeRequired = (m_Bih.biWidth * 24 + 31) / 32 * 4 * m_Bih.biHeight;是什么意思?
- 请教一个IE的问题
- C++BUILDER在的线程问题
- odbc数据库光标的错误,好几天没解决,帮忙!!!!!!!
- 如何动态改变组合框的编辑框的可写性?
- 执行时出Debug Assertion Failed!对话框
- 窗口拖动问题
- 1+1=?
- VC调试的时候出现赋值问题
CWnd::FromHandle(hWndParent), hInst)
返回是零 其中
lpDialogTemplate ==肯定有效的指针值
hWndParent ==看样子也是个有效的
hInst = 0x 100000
CWnd* pParentWnd, HINSTANCE hInst)中
if (hWnd != NULL && !(m_nFlags & WF_CONTINUEMODAL))
{
::DestroyWindow(hWnd); //函数没有执行到这里
hWnd = NULL;
}if (hTemplate != NULL)
{
GlobalUnlock(hTemplate); //也没有执行到这里
GlobalFree(hTemplate);
}// help with error diagnosis (only if WM_INITDIALOG didn't EndDialog())
if (hWnd == NULL && (m_nFlags & WF_CONTINUEMODAL))
{
#ifdef _DEBUG
#ifndef _AFX_NO_OCC_SUPPORT
if (afxOccManager == NULL) //到了 这里
{
TRACE0(">>> If this dialog has OLE controls:\n");
TRACE0(">>> AfxEnableControlContainer has not been called yet.\n");
TRACE0(">>> You should call it in your app's InitInstance function.\n");
}
else if (dwError != 0)
{//没有执行这里
TRACE1("Warning: Dialog creation failed! GetLastError returns 0x%8.8X\n", dwError);
}
#endif //!_AFX_NO_OCC_SUPPORT
#endif //_DEBUG
return FALSE;//执行了这该死的一步
} ASSERT(hWnd == m_hWnd);
TRACE和OutputDebugString。
就是CWnd::CreateDlgIndirect 失败吗
救命啊 ~~~
建议你在DoModal后面加上消息循环
while(::GetMessage(...))
{
::TranslateMessage
::DispatchMessage
}
问题好像处在对话框没有产生自己的消息循环
而这应该是DoModal默认产生的
afc大侠 太感谢你了 呵呵