WM_DESTROY Windows event loop

WM_DESTROY Windows event loop

?My Fortran code is compiled as a windows program with an event loop. The event loop handles
the WM_DESTROY message which is used to abort the run when the GUI wants to kill it.
When performing heavy computations, this abort only works sporadically. I think that the
Windows message cue fills up and the events are not handled.

Is there a way to force it to handle cued messages? Is there some other means that I should use to
externally abort the program? I would rather not deal with any mixed/C language calls.

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

What's your message loop like? You're supposed to catch WM_DESTROY in MainWndProc and call PostQuitMessage(0) on that.

But, in general, heavy computations don't fit well with message loops -- when the code is single-threaded it can execute either message loop or the computation but one or another must wait for the other to complete.

ThreadDlg sample on my home page offers a solution with a worker thread; it is not exactly the same as your problem but you may want to take a look at it.

Jugoslav

Jugoslav
www.xeffort.com

Quoting - steve999
?My Fortran code is compiled as a windows program with an event loop. The event loop handles
the WM_DESTROY message which is used to abort the run when the GUI wants to kill it.
When performing heavy computations, this abort only works sporadically. I think that the
Windows message cue fills up and the events are not handled.

Is there a way to force it to handle cued messages? Is there some other means that I should use to
externally abort the program? I would rather not deal with any mixed/C language calls.

I recomend you to change all windows management of your program to write in more Object oriented languajes, like VB or C#. I made a Windows program like you in fortran and was a very troble dealing with windows. VB or C# make those problems managed by the system and you dont worry in addition you can have all the capabilities of .NET. I already use fortran but only for numerics in operations i want to performance memory and cpu time.

Quoting - kooka

I recomend you to change all windows management of your program to write in more Object oriented languajes, like VB or C#. I made a Windows program like you in fortran and was a very troble dealing with windows. ...

The foregoing comment is entirely a matter of opinion (and experience, or lack thereof). If you take the trouble to learn how Windows works, then full-bore Win32 API programs written in Fortran are no more difficult than in any other language and there is no aspect of Win32 programming which cannot be done entirely in Fortran. This avoids the complexity of mixed-language programming (probably 20% of the threads in this forum are about problems with argument passing between Fortran and other languages).

As noted in other replies, you need to put your computation in a separate thread from the winmain message loop.

Quoting - Paul Curtis

Jeez, I just realized the original post in this thread was from 2002! Why are we still talking about this?

Leave a Comment

Please sign in to add a comment. Not a member? Join today