DBTechnique
asked on
CMultiDocTemplate::CreateNewFrame returns NULL the second time
Hello,
I am having a trouble with the CreateNewFrame function from CMultiDocTemplate.
The first time I use it, it works fine and my window opens correclty. If I try to open a new one, once again everything is fine and I can see my two windows.
Now if I close all the windows that were opened previously, I can't anymore create a new window since CreateNewFrame always returns NULL.
I am thinking I must miss something pretty dumb...
I am having a trouble with the CreateNewFrame function from CMultiDocTemplate.
The first time I use it, it works fine and my window opens correclty. If I try to open a new one, once again everything is fine and I can see my two windows.
Now if I close all the windows that were opened previously, I can't anymore create a new window since CreateNewFrame always returns NULL.
I am thinking I must miss something pretty dumb...
// Creation of the template
pDocTemplate = new CMultiDocTemplate(IDR_RESOURCE,
pDoc->GetRuntimeClass(),
RUNTIME_CLASS(CMyWnd),
RUNTIME_CLASS(CMyView));
AddDocTemplate(pDocTemplate);
void func()
{
// Creation of one view
CMyWnd* pMyWnd = (CMyWnd*)m_pDocTemplate->CreateNewFrame(pDoc, NULL);
if (pMyWnd)
pDocTemplate->InitialUpdateFrame(pMyWnd, pDoc);
}
Step into CreateNewFrame() and try to understand where it fails
ASKER
Hello,
I did that but it seems that the code I go into is not the one I am viewing in the editor (the cursor just jump without any consistency to the code).
So no chance to get information from here.
I did that but it seems that the code I go into is not the one I am viewing in the editor (the cursor just jump without any consistency to the code).
So no chance to get information from here.
How and where are you calling func() ?
Which version of visual studio ?
Which version of visual studio ?
ASKER
Hello,
My version is VS2008, MFC 9.0.
All this code is in a DLL.
When I click the menu, my menu manager transfers the event to func().
Then in func, I first switch the resources to those of my DLL and then do the call the CreateNewFrame(...).
If it is of any importance, the document class is a "dumb" class derivated from CDocument with no special behaviour.
My version is VS2008, MFC 9.0.
All this code is in a DLL.
When I click the menu, my menu manager transfers the event to func().
Then in func, I first switch the resources to those of my DLL and then do the call the CreateNewFrame(...).
If it is of any importance, the document class is a "dumb" class derivated from CDocument with no special behaviour.
>>>>> I did that but it seems that the code I go into is not the one I am viewing in the editor
Look in the output window in order to see form which path the dll is loaded
Look in the output window in order to see form which path the dll is loaded
ASKER
Hello,
Do you mean the MFC dll ?
I have those information from the Output window :
Loaded 'C:\Windows\System32\ntdll .dll'
Loaded 'C:\Windows\System32\kerne l32.dll'
Loaded 'C:\Windows\System32\Kerne lBase.dll'
Loaded 'C:\Windows\winsxs\x86_mic rosoft.vc9 0.debugmfc _1fc8b3b9a 1e18e3b_9. 0.30729.41 48_none_2f 2cc1b4522c ec06\mfc90 ud.dll', Symbols loaded.
Loaded 'C:\Windows\winsxs\x86_mic rosoft.vc9 0.debugcrt _1fc8b3b9a 1e18e3b_9. 0.30729.41 48_none_2a 4cbfc25558 bcd3\msvcr 90d.dll', Symbols loaded.
Loaded 'C:\Windows\System32\user3 2.dll'
Loaded 'C:\Windows\System32\gdi32 .dll'
Loaded 'C:\Windows\System32\lpk.d ll'
Loaded 'C:\Windows\System32\usp10 .dll'
Loaded 'C:\Windows\System32\msvcr t.dll'
Loaded 'C:\Windows\System32\shlwa pi.dll'
Loaded 'C:\Windows\winsxs\x86_mic rosoft.win dows.commo n-controls _6595b6414 4ccf1df_6. 0.7600.163 85_none_42 1189da2b7f abfc\comct l32.dll'
Loaded 'C:\Windows\System32\msimg 32.dll'
Loaded 'C:\Windows\System32\oleau t32.dll'
Loaded 'C:\Windows\System32\ole32 .dll'
Loaded 'C:\Windows\System32\rpcrt 4.dll'
Loaded 'C:\Windows\System32\ws2_3 2.dll'
Loaded 'C:\Windows\System32\nsi.d ll'
Loaded 'C:\Windows\System32\advap i32.dll'
Loaded 'C:\Windows\System32\secho st.dll'
Loaded 'C:\Windows\System32\shell 32.dll'
Loaded 'C:\Windows\System32\wsock 32.dll'
Loaded 'C:\Windows\winsxs\x86_mic rosoft.vc9 0.mfc_1fc8 b3b9a1e18e 3b_9.0.307 29.4148_no ne_4bf5400 abf9d60b7\ mfc90u.dll ', Symbols loaded.
Loaded 'C:\Windows\winsxs\x86_mic rosoft.vc9 0.crt_1fc8 b3b9a1e18e 3b_9.0.307 29.4926_no ne_508ed73 2bcbc0e5a\ msvcr90.dl l'
Loaded 'C:\Windows\winsxs\x86_mic rosoft.vc9 0.crt_1fc8 b3b9a1e18e 3b_9.0.307 29.4926_no ne_508ed73 2bcbc0e5a\ msvcp90.dl l'
Loaded 'C:\Windows\System32\versi on.dll'
Loaded 'C:\Windows\System32\comdl g32.dll'
Loaded 'C:\Windows\System32\apphe lp.dll'
Loaded 'C:\Windows\AppPatch\AcLay ers.dll'
Loaded 'C:\Windows\System32\sspic li.dll'
Loaded 'C:\Windows\System32\usere nv.dll'
Loaded 'C:\Windows\System32\profa pi.dll'
Loaded 'C:\Windows\System32\winsp ool.drv'
Loaded 'C:\Windows\System32\mpr.d ll'
Loaded 'C:\Windows\System32\imm32 .dll'
Loaded 'C:\Windows\System32\msctf .dll'
Loaded 'C:\Windows\System32\avgrs stx.dll'
Loaded 'C:\Windows\System32\uxthe me.dll'
Loaded 'C:\Windows\System32\dwmap i.dll'
Loaded 'C:\Windows\winsxs\x86_mic rosoft.vc9 0.mfcloc_1 fc8b3b9a1e 18e3b_9.0. 30729.4148 _none_4973 eb1d754a9d c9\MFC90EN U.DLL', Binary was not built with debug information.
Loaded 'C:\Windows\System32\icmp. dll'
Loaded 'C:\Windows\System32\IPHLP API.DLL'
Loaded 'C:\Windows\System32\winns i.dll'
Loaded 'C:\Windows\System32\crypt base.dll'
Loaded 'C:\Windows\System32\ntmar ta.dll'
Loaded 'C:\Windows\System32\Wldap 32.dll'
Loaded 'C:\Windows\System32\perfp roc.dll'
Unloaded 'C:\Windows\System32\perfp roc.dll'
Loaded 'C:\Windows\System32\mswso ck.dll'
Loaded 'C:\Windows\System32\WSHTC PIP.DLL'
Loaded 'C:\Windows\System32\clbca tq.dll'
Loaded 'C:\Windows\System32\IME\I MEJP10\IMJ PTIP.DLL'
Loaded 'C:\Windows\System32\oleac c.dll'
Loaded 'C:\Windows\System32\IMJP1 0K.DLL'
Loaded 'C:\Windows\System32\IME\s hared\IMET IP.DLL'
Loaded 'C:\Windows\System32\IME\s hared\imec fm.dll'
Loaded 'C:\Windows\System32\IME\I MEJP10\IMJ PAPI.DLL'
Loaded 'C:\Windows\System32\IME\s hared\IMJK API.DLL'
Loaded 'C:\Windows\System32\openg l32.dll'
Loaded 'C:\Windows\System32\ddraw .dll'
Loaded 'C:\Windows\System32\dcima n32.dll'
Loaded 'C:\Windows\System32\setup api.dll'
Loaded 'C:\Windows\System32\cfgmg r32.dll'
Loaded 'C:\Windows\System32\devob j.dll'
Loaded 'C:\Windows\winsxs\x86_mic rosoft.win dows.gdipl us_6595b64 144ccf1df_ 1.1.7600.1 6385_none_ 72fc7cbf86 1225ca\Gdi Plus.dll'
Do you mean the MFC dll ?
I have those information from the Output window :
Loaded 'C:\Windows\System32\ntdll
Loaded 'C:\Windows\System32\kerne
Loaded 'C:\Windows\System32\Kerne
Loaded 'C:\Windows\winsxs\x86_mic
Loaded 'C:\Windows\winsxs\x86_mic
Loaded 'C:\Windows\System32\user3
Loaded 'C:\Windows\System32\gdi32
Loaded 'C:\Windows\System32\lpk.d
Loaded 'C:\Windows\System32\usp10
Loaded 'C:\Windows\System32\msvcr
Loaded 'C:\Windows\System32\shlwa
Loaded 'C:\Windows\winsxs\x86_mic
Loaded 'C:\Windows\System32\msimg
Loaded 'C:\Windows\System32\oleau
Loaded 'C:\Windows\System32\ole32
Loaded 'C:\Windows\System32\rpcrt
Loaded 'C:\Windows\System32\ws2_3
Loaded 'C:\Windows\System32\nsi.d
Loaded 'C:\Windows\System32\advap
Loaded 'C:\Windows\System32\secho
Loaded 'C:\Windows\System32\shell
Loaded 'C:\Windows\System32\wsock
Loaded 'C:\Windows\winsxs\x86_mic
Loaded 'C:\Windows\winsxs\x86_mic
Loaded 'C:\Windows\winsxs\x86_mic
Loaded 'C:\Windows\System32\versi
Loaded 'C:\Windows\System32\comdl
Loaded 'C:\Windows\System32\apphe
Loaded 'C:\Windows\AppPatch\AcLay
Loaded 'C:\Windows\System32\sspic
Loaded 'C:\Windows\System32\usere
Loaded 'C:\Windows\System32\profa
Loaded 'C:\Windows\System32\winsp
Loaded 'C:\Windows\System32\mpr.d
Loaded 'C:\Windows\System32\imm32
Loaded 'C:\Windows\System32\msctf
Loaded 'C:\Windows\System32\avgrs
Loaded 'C:\Windows\System32\uxthe
Loaded 'C:\Windows\System32\dwmap
Loaded 'C:\Windows\winsxs\x86_mic
Loaded 'C:\Windows\System32\icmp.
Loaded 'C:\Windows\System32\IPHLP
Loaded 'C:\Windows\System32\winns
Loaded 'C:\Windows\System32\crypt
Loaded 'C:\Windows\System32\ntmar
Loaded 'C:\Windows\System32\Wldap
Loaded 'C:\Windows\System32\perfp
Unloaded 'C:\Windows\System32\perfp
Loaded 'C:\Windows\System32\mswso
Loaded 'C:\Windows\System32\WSHTC
Loaded 'C:\Windows\System32\clbca
Loaded 'C:\Windows\System32\IME\I
Loaded 'C:\Windows\System32\oleac
Loaded 'C:\Windows\System32\IMJP1
Loaded 'C:\Windows\System32\IME\s
Loaded 'C:\Windows\System32\IME\s
Loaded 'C:\Windows\System32\IME\I
Loaded 'C:\Windows\System32\IME\s
Loaded 'C:\Windows\System32\openg
Loaded 'C:\Windows\System32\ddraw
Loaded 'C:\Windows\System32\dcima
Loaded 'C:\Windows\System32\setup
Loaded 'C:\Windows\System32\cfgmg
Loaded 'C:\Windows\System32\devob
Loaded 'C:\Windows\winsxs\x86_mic
>>> Do you mean the MFC dll ?
No, your dll
No, your dll
ASKER
Hello,
My DLL is loaded from the a subfolder of my application.
The ouput window is confirming that.
My DLL is loaded from the a subfolder of my application.
The ouput window is confirming that.
ASKER
Hello,
I have some more information.
I can't remember what I did and when I look at the code, only the view class has changed, but now, instead of not opening the window, it crash when trying to do it.
Still in the CreateNewFrame function.
The crash happens when calling the CMDIChildWnd::LoadFrame function.
I have some more information.
I can't remember what I did and when I look at the code, only the view class has changed, but now, instead of not opening the window, it crash when trying to do it.
Still in the CreateNewFrame function.
The crash happens when calling the CMDIChildWnd::LoadFrame function.
May be you have some problems with loading resources
ASKER
Hello,
Yes it seems so, but I don't understand why it doesn't happen the first time.
I could create more than 40 windows without problems, but as soon as they are all closed, then I can't make a new one.
Also the crash is occuring within the function CDocument::AddView, when trying to call CPtrList::AddTail()
Yes it seems so, but I don't understand why it doesn't happen the first time.
I could create more than 40 windows without problems, but as soon as they are all closed, then I can't make a new one.
Also the crash is occuring within the function CDocument::AddView, when trying to call CPtrList::AddTail()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
where does the 'pDoc' come from you use in the 'func'?
Do you re-use that 'pDoc' in all frames/views? If so simply the 'pDoc' maybe deleted when the last frame/view is destroyed and creating a new one fails since 'pDoc' points to nirwana ...
ZOPPO
where does the 'pDoc' come from you use in the 'func'?
Do you re-use that 'pDoc' in all frames/views? If so simply the 'pDoc' maybe deleted when the last frame/view is destroyed and creating a new one fails since 'pDoc' points to nirwana ...
ZOPPO
Sorry, alb66, forgot to refresh befor I submitted this - please ignore ...
Hey Zoppo, don't worry ;-)
ASKER
ehehe thanks a lot !
That's exactly what happened.
After I close the last view, the document is no more valid.
Thanks again Alb66 !
That's exactly what happened.
After I close the last view, the document is no more valid.
Thanks again Alb66 !