|
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)
|
|
|
|
|
Hi all,
I'm having a very difficult time trying to display a bunch of data to a view and to the printer.
I'm using MFC's document/view arch with a single view derived from CScrollView. What I'm trying to do is based on the file opened by the user, I generate a document (which is more like a datawarehouse containing info retrieved from the file, NOT in the same format in the file). From that document I am trying to display a text-based view to the screen using CDC's text output functions and the Gdi objects to change the colors, font, etc.
My problem is getting the text to look presentable. I seem to be missing something in how to approach drawing the text in such a way that it has rows/columns and is centered and aligned properly. An example is this:
General Info
Data 1: somedata
Data 10: mordata
....
Does anyone have any suggestions? I don't know a ton about MFC so I don't know if I can changes things quickly other than the way the text is being drawn.
Any suggestions, comments or ideas are GREATLY appreciated.
Thanks!!
Dan
|
|
|
|
|
What you're trying to do is very messy, to say the least. A simpler alternative is to use CHtmlView and format your data for presentation as a simple HTML doc.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquin,
Thanks for the advice. That does seem much easier than what I was attempting. I could just create and HTML document and then display that document in the view. But there is still another issue that I'll have which I'm unsure how to approach using this method. I need to be able to print the document from my current application, preferably allowing the print preview as well. Any suggestions as to how I can do this? Is there any difference than using CScrollView? I really need to be able to print from my app.
Any suggestions/comments/ideas are GREATLY appreciated.
Thanks!!!!!
Joaquín M López Muñoz wrote:
What you're trying to do is very messy, to say the least. A simpler alternative is to use CHtmlView and format your data for presentation as a simple HTML doc.
|
|
|
|
|