Assert Modal Dialog wincore.cpp
-
hey folks, i stumbled across an assertion in my program. When I want to show a dialog modally the dialog is shown correctly, but when I close the dialog I get an assert: "Debug assertion failed! ... program ...wincore.cpp line 882" which is:
void CWnd::AssertValid() const
{
if (m_hWnd == NULL)
return; // null (unattached) windows are valid// check for special wnd??? values ASSERT(HWND\_TOP == NULL); // same as desktop if (m\_hWnd == HWND\_BOTTOM) ASSERT(this == &CWnd::wndBottom); else if (m\_hWnd == HWND\_TOPMOST) ASSERT(this == &CWnd::wndTopMost); else if (m\_hWnd == HWND\_NOTOPMOST) ASSERT(this == &CWnd::wndNoTopMost); else { // should be a normal window ASSERT(::IsWindow(m\_hWnd)); //<-- HERE
My code is farely simple:
CSelectionDlg dlg;
dlg.DoModal();the thing is: I call this from a member-class:
-MyDialogDlg my dialog
-SomeClass m_instanceOfClass; a memberclass of dialog.
a function of Someclass does the above codeI found some stuff from microsoft: http://support.microsoft.com/kb/194300/eng which didn't work for my case! if I add
ASSERT(::IsWindow(m_hWnd));
before the domodal nothing changes... so somehow my handle gets lost and I donnu what to do. can anybody help? maybe a simple link. i tried many links, although nothing worked for my case. I don't have any crazy stuff in my OnInit of the dialog nor do I have another dialog as model dialog thx for your help zqueezy
-
hey folks, i stumbled across an assertion in my program. When I want to show a dialog modally the dialog is shown correctly, but when I close the dialog I get an assert: "Debug assertion failed! ... program ...wincore.cpp line 882" which is:
void CWnd::AssertValid() const
{
if (m_hWnd == NULL)
return; // null (unattached) windows are valid// check for special wnd??? values ASSERT(HWND\_TOP == NULL); // same as desktop if (m\_hWnd == HWND\_BOTTOM) ASSERT(this == &CWnd::wndBottom); else if (m\_hWnd == HWND\_TOPMOST) ASSERT(this == &CWnd::wndTopMost); else if (m\_hWnd == HWND\_NOTOPMOST) ASSERT(this == &CWnd::wndNoTopMost); else { // should be a normal window ASSERT(::IsWindow(m\_hWnd)); //<-- HERE
My code is farely simple:
CSelectionDlg dlg;
dlg.DoModal();the thing is: I call this from a member-class:
-MyDialogDlg my dialog
-SomeClass m_instanceOfClass; a memberclass of dialog.
a function of Someclass does the above codeI found some stuff from microsoft: http://support.microsoft.com/kb/194300/eng which didn't work for my case! if I add
ASSERT(::IsWindow(m_hWnd));
before the domodal nothing changes... so somehow my handle gets lost and I donnu what to do. can anybody help? maybe a simple link. i tried many links, although nothing worked for my case. I don't have any crazy stuff in my OnInit of the dialog nor do I have another dialog as model dialog thx for your help zqueezy
Did you try to trace your code line to line it seems you have a unvalid hwnd on your code.
-
Did you try to trace your code line to line it seems you have a unvalid hwnd on your code.
-
I would expect your ASSERT placed before the DoModal() to succeed, it just means that you are calling DoModal() from a CWnd derived class that has a valid Window, it has no bearing on the state of the dialog. Are you calling DestroyWindow() somewhere in your Dialog class?