问题描述
我已经编写了一个程序,该程序可以在Windows SP2和SP3上运行,但是今天它不能在一个同事的计算机上正常工作.我已经尝试过其他人的计算机,它始终可以正常运行.因此,我使用MessageBox调试程序.当我使用EndDialog关闭模式对话框时,它失败并且GetLastError代码为:
1420,ERROR_NOT_WINDOW_DIALOG
.
我不知道为什么我还使用SendMessage重播EndDialog以关闭对话框.但是我看不到Spy ++中的WM_CLOSE.当我使用ALT + F4关闭对话框时,SendMessage可以正常工作.我很困惑!
CWnd * pWnd = FindWindow(NULL,_T(" 进度" ) ); 如果(pWnd!= NULL) { BOOL bResult = :: EndDialog(pWnd-> m_hWnd,IDOK); 如果(bResult) { MessageBox(_T(" OK" )); } 其他 { CString strMsg; strMsg.Format(_T(" 不好%d" ),GetLastError()); MessageBox(strMsg); } }
否则,您可以使用SendMessage退出窗口
公共 const int WM_COMMAND = 0x0112; 公共 常量 int WM_CLOSE = 0xF060;
SendMessage(pWnd,WM_COMMAND,WM_CLOSE,0);
I have written a program, it can run on Windows SP2 and SP3, but today it can not work correctly on one colleague''s computer. I have tried other person''s computer, where it always work well. So I use MessageBox to debug the program. When I use EndDialog to close a modal dialog, it failed and GetLastError code is:
1420, ERROR_NOT_WINDOW_DIALOG
.
I don''t know why. I also use SendMessage to replay EndDialog to close the dialog. But I can''t see WM_CLOSE in Spy++. When I use ALT+F4 close the dialog, then SendMessage can work well. I was very confusing!
CWnd* pWnd = FindWindow(NULL, _T("Progress")); if (pWnd != NULL) { BOOL bResult = ::EndDialog(pWnd->m_hWnd, IDOK); if (bResult) { MessageBox(_T("OK")); } else { CString strMsg; strMsg.Format(_T("NOT OK %d"), GetLastError()); MessageBox(strMsg); } }
这篇关于EndDialog失败,并显示GetlastError代码1420的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!