programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Re: Access Violation on Application exit

From: Mike Ghan <mikeghan_at_logix-controls.com>
Date: Tue, 18 Sep 2001 16:36:25 -0700

Bob, all Windows programs need a message dispatcher loop. A message
dispatcher loop is started with the SF console program. Standalone
programs need to start their own message dispatcher loop. The word
DISPATCHER is a simple dispatcher suitable for many programs. Take a
look at WINMAIN in Win2.F in the samples directory:

: WINMAIN ( -- )
   1 TO APPLICATION DEMO DISPATCHER 0 ExitProcess ;

WINMAIN first sets a flag APPLICATION used by APP-DESTROY to determine
if this is a turnkey program. Next, WINMAIN calls DEMO which
"kicks-off" the application by creating the main window. The first
thing (almost) a new windows does is post various messages to the
application message queue, for example WM_CREATE. DISPATCHER will then
loop forever waiting for messages and dispatching messages to the
application until a WM_QUIT message is encountered, typically via the
PostQuitMessage function. WINMAIN will then continue and execute "0
ExitProcess" which will then terminate the application.

The word WINMAIN should only be executed at the start of a turnkey
program and not from a console session.

To test the application from the console, use DEMO. DEMO will not set
the flag APPLICATION true so when the application's window is destroyed,
PostQuitMessage is not executed. See APP-DESTROY in Win2.F.

Hope this is useful,

Mike

-----Original Message-----
From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com]On Behalf
Of Robert Dickow
Sent: Tuesday, September 18, 2001 3:09 PM
To: sftalk_at_forth.com
Subject: [sftalk] Re: Access Violation on Application exit

I can't really post the source...it's several thousand lines of code. It
only gives the "Access Violation" upon shut down of the turnkeyed app,
not
when run from the console.

As for the BYE, I thought it *had* to be used upon exiting the program.
To
clarify, I exit the actual app from a Quit command in a program window,
and
then the code goes through the usual DestroyWindow etc. But when the
program
has set up the message loops and whatnot, then it exits with a BYE.
Without
that the program crashes almost immediately upon execution. If not a
BYE,
what is the recommended method of setting up a turnkeyed app?

Bob
***********************************
** Robert Dickow (dickow_at_uidaho.edu) **
** USDA Zone 5 ** Vive le cor!! **
***********************************

----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe sftalk" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/sftalk -- check them out!
Search the archives! Visit http://www.forth.com/search for details.
Received on Tue Sep 18 2001 - 16:36:21 PDT

This archive was generated by hypermail 2.2.0 : Fri Nov 21 2008 - 03:04:19 PST