Problems with an MDI application
I have an MDI application with a FormView instead of a view.
On one of the menu picks I call a modeless sample sheet to get data from a database and then plot it on this Formview.THe problem is when I click on
'New Window' after I call the dialog it gives me a DEBUG ASSERTION saying
ASSERT
WinMDI.cpp on line 510.I think its not able to find the childwnd but I am not sure how to go about fixing this.Any suggestions??
THanks
[457 byte] By [
spshastr] at [2007-11-19 6:38:10]

# 1 Re: Problems with an MDI application
Can you post the the code sample in your Menu Handler. With this cant say
something.
# 2 Re: Problems with an MDI application
MEnu handler doesnt have much code .
In the menu I have a login menu pick and when the user logs in
I show a modeless property sheet and they can download data with different properties set.As soon as the data gets downloaded I have to plot a chart in the view.I have a Plot button on the view and it plots fine.
Now the problem is the menu pick has a'New Window' and when thats done it gives me the ASSERT FAILURE.My guess is its not finding the hadle for the child window and my question is how do I force it to create the child Window again.
It goes to MFC code so I was not sure how.
THanks
# 3 Re: Problems with an MDI application
The problem is that you are trying to create MDI child frame window before either main window was not created or pointer to a main windows has not been initialized. of course assuming that assertion is really caused by your handler and if line number is correct.
As Vinod S suggested code snippet would be helpful.
Are you calling this menu handler when application is loaded? It is important to know when and where your code is used.
What is that dialog you mentioned?
It does not matter how much code you have. One line is enough to create havoc.
JohnCz at 2007-11-11 0:32:31 >

# 4 Re: Problems with an MDI application
if(pParentWnd=NULL)
{
CWnd* pMainWnd = AfxGetThread()->m_pMainWnd;
ASSERT(pMainWnd != NULL);
ASSERT_KINDOF(CMDIFrameWnd, pMainWnd);
pParentWnd = (CMDIFrameWnd*)pMainWnd;
}
It fails on the ASSERT_KINDOF as the handler is the dialogs and not he CMDIFRAMEWNDS.I wanted to get the CMDIFRAMEWNDS handler.
THanks
# 5 Re: Problems with an MDI application
if(pParentWnd=NULL)
if i am not wrong this is Comparison or Assignment...check the if condition...
venky
# 6 Re: Problems with an MDI application
if(pParentWnd==NULL)
{
CWnd* pMainWnd = AfxGetThread()->m_pMainWnd;
ASSERT(pMainWnd != NULL);
ASSERT_KINDOF(CMDIFrameWnd, pMainWnd);
pParentWnd = (CMDIFrameWnd*)pMainWnd;
}
gives an error too.
First time I run the Application it works fine.THen on the menu pick I have a pick to go to a dialog bvox and then when I come back and try
'New Window'
it gives me an ASSERT failure on this.
# 7 Re: Problems with an MDI application
have a look at the attachement, hope this can help..you...
venky :thumb:
# 8 Re: Problems with an MDI application
THANKS A LOT!!IT WORKS!!THANKS AGGAIN.THANKS A LOTTTT.I AM SO HAPPY
Heres the code I have in the onLogin menu handler
CSampleSheet *m_dlgpropertysheet=new CSampleSheet("Sample Application");
ASSERT(m_dlgpropertysheet);
_snprintf(m_dlgpropertysheet->m_szTitle, sizeof(m_dlgpropertysheet->m_szTitle)-1, "%s - Sample Application",
ApiVersion.szDescription);
//CWnd *CWinThread m_hWnd=m_dlgpropertysheet;
pApp->m_pMainWnd=m_dlgpropertysheet;(THIS WAS THE PROBLEM)
m_dlgpropertysheet->Create();
# 9 Re: Problems with an MDI application
Hello:
I have an MDI application and I can show one of the forms of the application if i write:
first I have the declaration of the form:
m_form= new CMultiDocTemplate(
IDR_FORM,
RUNTIMECLASS(CProyectoDoc),
RUNTIMECLASS(CChildFrame),
RUNTIMECLASS(CMYFORM));
and after i can access that form if i write:
((CProyectoApp *)AfxGetApp())->m_form->OpenDocuemntFile(NULL);
But now i'm trying to open the form from a Thread, and i always have the error in the line 510 of winmdi.cpp
Could you help me, please??
Thansk a lot
lopez at 2007-11-11 0:38:40 >
