Re: Terminating

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Coming back to this situation after some weeks have passed,

AfxGetMainWnd()->PostMessage(WM_CLOSE) is working cleanly now. I had been
posting it too deeply within a series of recurring calls and loops.

Once again, thanks for the essential aid.
--------------

"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:nh7st1l5sjonvjkt25jk0u7mrvjfqjjf28@xxxxxxxxxx
Could it be that your program has a bug? Note that if posting a WM_CLOSE
message fails,
then any other attempt to close your app should fail. This would
represent an erroneous
program. Are you using any threads? If so, are you making sure they shut
down correctly?
joe


On Mon, 30 Jan 2006 07:21:57 -0500, "Steve Russell"
<srussell@xxxxxxxxxxxxxxxxxxxxxx>
wrote:

For instance, my View pointer is no longer valid. Nor are perhaps any of
my
custom classes. The program attempts to keep running and quickly gets
into
trouble on that basis. I will take a closer look. It could be that I
need
to break out of any calling loops at the point of the error.
------------
"M" <a@xxxxx> wrote in message
news:eOcTDAVJGHA.2696@xxxxxxxxxxxxxxxxxxxxxxx
What sort of variables?


"Steve Russell" <srussell@xxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:e6skTUUJGHA.1032@xxxxxxxxxxxxxxxxxxxxxxx
Thanks, M. Actually, these WM_CLOSE messages are crashing my program,
hanging up on variable that no longer have legit values. I am not sure
what to do.
------------
"M" <a@xxxxx> wrote in message
news:%23xq1kSTJGHA.3856@xxxxxxxxxxxxxxxxxxxxxxx
If I may be so bold...

: )

Try ::PostMessage(AfxGetApp()->m_pMainWnd->GetSafeHwnd(), WM_CLOSE,
0,
0);




"Steve Russell" <srussell@xxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:O9aFGYSJGHA.2668@xxxxxxxxxxxxxxxxxxxxxxx
Bob, thank you very much! Now I have:

m_pView->PostMessage(WM_CLOSE);

How does this relate to my main window in my SDI? Should I do
something different?
-----------
<Bob Moore> wrote in message
news:to2qt192q5dot6i8nvnjuhbajf921fg75m@xxxxxxxxxx
On Sat, 28 Jan 2006 18:49:15 -0500, Steve Russell wrote:

What is the best way to terminate an MFC application, for instance,
in
the
event of certain kinds of errors?

Post a WM_CLOSE to your main window. The default handler will shut
down the app cleanly (if you haven't over-ridden it and done
something
funky).

Using WM_QUIT will simply quit the main message loop, which means
your
windows won't get the opportunity for proper clean-up. Functional,
but
only one step up from terminating the process.

--
Bob Moore
http://bobmoore.mvps.org/
(this is a non-commercial site and does not accept advertising)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do not reply via email unless specifically requested to do so.
Unsolicited email is NOT welcome and will go unanswered.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~









Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm


.



Relevant Pages

  • Re: Terminating
    ... How does this relate to my main window in my SDI? ... <Bob Moore> ... >>What is the best way to terminate an MFC application, for instance, in the ... > Unsolicited email is NOT welcome and will go unanswered. ...
    (microsoft.public.vc.mfc)
  • Re: Hadnling windows messages when in big loop
    ... www.getdotnetcode.com "Fred Flintstone" wrote in message ... >I have a project, that loops through a lot of wmi queries, and while its>looping, the window will not repaint, I can't move or size the window. ... > I remember having a similar problem back in an excel macro, and I ran a> command that told the application to process windows messages. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Hadnling windows messages when in big loop
    ... > Mike McIntyre ... >>I have a project, that loops through a lot of wmi queries, and while its ... >>looping, the window will not repaint, I can't move or size the window. ... >> command that told the application to process windows messages. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: gradient using linear regression
    ... I need to do a linear regression ... over the window and take the line slope as the derivative. ... do it faster either by avoiding using loops or some other ways. ... Use the explicit regression formulas instead of Matlab's ...
    (comp.soft-sys.matlab)
  • Hadnling windows messages when in big loop
    ... I have a project, that loops through a lot of wmi queries, and while its ... looping, the window will not repaint, I can't move or size the window. ... command that told the application to process windows messages. ...
    (microsoft.public.dotnet.languages.vb)