|
BOOL CTrain1App::InitInstance()
{
AfxEnableControlContainer();
#ifdef _AFXDLL
Enable3dControls();
#else
Enable3dControlsStatic();
#endif
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings();
AfxInitRichEdit();
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_TRAIN1TYPE,
RUNTIME_CLASS(CTrain1Doc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CTrain1View));
AddDocTemplate(pDocTemplate);
m_pView1Template = pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_TRAIN1TYPE,
RUNTIME_CLASS(CTrain1Doc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CDlgLists));
m_pView2Template = pDocTemplate;
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (!ProcessShellCommand(cmdInfo))
return FALSE;
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
|
|
|
|
|
I don't see any use of CFileDialogST here (thought you were launching at start up before UI).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Sorry. The code is in a function that is triggered in OnInitDialog (in View) after it queries the registry to see if info exists. If not, this function runs. However this same function can be called from a menu selection once the app is up and running. Its when I cancel at this point, that I get the crash.
Is this clearer. So sorry for miscommunicating...
(I had really wanted the blank UI to come up on which the CFileDlg should sit waiting, but the postmessage I used to trigger my function was having probs, which I fixed with sendmessage, so now it just brings the CFileDlg up instead.)
|
|
|
|
|
Let's keep on rocking. Replace WM_CLOSE with ID_APP_EXIT (and tell us what happens).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Ha! It blithely ignored
AfxGetMainWnd()->PostMessage(ID_APP_EXIT);
, same as it does
PostQuitMessage(0) .
At least it doesnt crash. It just doesnt want to terminate!
|
|
|
|
|
Doesnt like plain old PostMessage(ID_APP_EXIT); either
|
|
|
|
|
Well, back to WM_CLOSE then. Another try: omit your OnDestroy and OnClose handlers entirely (i.e, delete them both from the .h and the .cpp of your main frame class). Waiting here
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Okay. Got rid of the OnClose() and Destroy() completely. Crashes with WM_CLOSE on cancel:
if(nRetValue == IDCANCEL)
{
AfxMessageBox ("No Image folder selected, terminating application");
AfxGetMainWnd()->PostMessage(WM_CLOSE);
}
|
|
|
|
|
Into which command handler is this code inserted?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
A menu item in the view class : CTrainView::OnSelectDatabase
The view class is handling it.
|
|
|
|
|
(This is getting surrealistic )
Won't you have by chance forgotten returning from OnSelectDatabase right after posting the quit message? If you have, then more code could be subsequently be executed that is causing the crash.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
So even after posting message (I also tried SendMessage) one needs to return! Esp sendMessage I thought would finish the app off immediately, so no return was needed, but apparently not!
Many many thanks.
ns
|
|
|
|
|
I have to take off for a couple of hours. I truly appreciate all the input. I'll be struggling with this later today, so if you are still around....
|
|
|
|
|
|
I've got a go to a party dinner in a few minutes, so the break's also good for me.
If you don't get to solve the problem and don't mind other's eyes peeping your code, zip your project and send it to me: I'll be able to load it into my VC++ next monday and could do a more thorough check.
Bye
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I didnt do a return; in my code after postmessage. No one (except for the latest post) said I had to.
Now I have
if(nRetValue == IDCANCEL)
{
AfxMessageBox ("No Image folder selected, terminating application");
AfxGetMainWnd()->PostMessage(WM_CLOSE);
<code>return</code>;
}
and by golly it works. I didnt think or imagine I'd need return.
Sorry if I've been an idiot and wasted everyones time!
ns
|
|
|
|
|
Wow! You'd actually help debug my code!!! I thank you so much for the offer. You resolved it this time, so I hope I can take a raincheck on your offer (too good!) next time I have a perplexing crash! Hope you enjoyed the party.
Thank you,
ns
|
|
|
|
|
I'm glad I was of an help. The party was fine, thanx. Happy programming.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Another debugging test. Omit the call to CFileDialogST within the view command handler and simply post the quit message. Still crashing?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes. I commented out the CFileSt stuff and put in a plain old AfxGetMainWnd()->PostMessage(WM_CLOSE);..it crashed.
WHat does this mean?
Thanks,
ns
|
|
|
|
|
Well, we have ruled out the CFileDialogST bit, at least possibilities are shortening.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I appreciate all your help!
|
|
|
|
|
Use AfxGetApp ()->CloseAllDocuments () . I am nearly sure that this is gonna work
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
<nobr>They say I'm lazy but it takes all my time
|
|
|
|
|
Sorry, use it this way:
AfxGetApp ()->HideApplication ();
AfxGetApp ()->CloseAllDocuments (TRUE);
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
<nobr>They say I'm lazy but it takes all my time
|
|
|
|
|
I did. It ignored it and went on to pop up another CFILedlg (the following code doe s that). Now fromn this second CFiledlg I have been able to cancel without problems before, but this time it crashes (the second dialog I meaqn. The first one just ignores it and goes away)
|
|
|
|