[comp.sys.atari.st] Closing desk accessories

Gribnif@umass (Dan Wilga at UMASS Amherst) (02/21/88)

Greetings!

Is there some way to actually "tell" desk accessories that are currectly
opened within an application to close? I am writing a program that uses
Pexec() to call other programs, but the problem I am running into is that
any DA's that occupy windows and are left open when my program executes
another do not receive the AC_CLOSE message and so do not know they should
be closed. Of course, I cannot simply close their windows for them; that
only messes them up. Pterm() somehow does this for itself since it
automagically sends the correct message when the application terminates.
shel_write() also seems to suffer from this same problem. Is there any
good solution, short of hacking-into the OS?

----------------------------------------------------------------------------
"In those days, men were real men,           Dan Wilga
 women were real women, and small
 furry creatures from Alpha Centauri         Gribnif@UMASS.Bitnet
 were REAL small furry creatures
 from Alpha Centauri" -- Hitchhikers

apratt@atari.UUCP (Allan Pratt) (02/24/88)

in article <8802210020416D5.BLBS@Mars.UCC.UMass.EDU>, Gribnif@umass (Dan Wilga at UMASS Amherst) says:
> 
> Greetings!
> 
> Is there some way to actually "tell" desk accessories that are currectly
> opened within an application to close? I am writing a program that uses
> Pexec() to call other programs, but the problem I am running into is that
> any DA's that occupy windows and are left open when my program executes
> another do not receive the AC_CLOSE message and so do not know they should
> be closed. Of course, I cannot simply close their windows for them; that
> only messes them up. Pterm() somehow does this for itself since it
> automagically sends the correct message when the application terminates.
> shel_write() also seems to suffer from this same problem. Is there any
> good solution, short of hacking-into the OS?

I think you hit on the solution without knowing it: closing their
windows doesn't pay, but you can SEND THEM the AC_CLOSE message (I
think).  Check the message library for "send a process a message" and
check the application library for "get ap_id for an accessory" (I don't
really know that much AES).  Then send the accessory the close message. 
Sending it wind_close is usually enough, since (like the Control Panel)
clicking "close" in the window usually shuts down the accessory as well. 

Failing that, you could try the opposite of app_init -- I forget its
name -- because I think it's that call which closes accessories, not
Pterm().  Pterm() doesn't know a thing about accessories, or AES, or
anything at that level.  So try app_deinit before the Pexec and app_init
after it.  (Remember that your window handles might be different after
the new init...  They probably won't be, but write your code as though
they might be.)

Like I said, I don't know much about AES -- don't take this as Gospel.

============================================
Opinions expressed above do not necessarily	-- Allan Pratt, Atari Corp.
reflect those of Atari Corp. or anyone else.	  ...ames!atari!apratt

Gribnif@UMass.BITNET (Dan Wilga at UMASS Amherst) (02/27/88)

Greetings!

In my previous letter I was looking for a way to close desk accessories before
using Pexec() to call a second GEM application from within a program. Well,
I have found something that seems to work (after finally discovering some
docs that actually explain the way appl_write() REALLY works). The following
code segment seems to do the trick.

  int buff[8], w_hand, i, AES_handle, dum;

  AES_handle = appl_init();            /* get the handle of my application */
    .
    .                                  /* the guts */
    .                                  /* close any windows still open */
  wind_get( 0, WF_TOP, &w_hand, &dum, &dum, &dum );  /* topmost window */
  while( w_hand > 0 ) {                /* until no more windows */
    wind_close( w_hand );
    wind_delete( w_hand );             /* now the next one down is top */
    wind_get( 0, WF_TOP, &w_hand, &dum, &dum, &dum );  /* get the next one */
  }

  buff[0] = AC_CLOSE;               /* emulate the message normally received */
  buff[1] = AES_handle;             /* handle of app. that caused the close */
  for( i=0; i<AES_handle; i++ ) {   /* assume the DAs have lower handles */
    buff[2] = 2+i;                  /* an educated guess */
    appl_write( i, 16, buff );      /* the message is read the next time the */
  }                                 /* DA does evnt_mesag() or evnt_multi() */

I am just wondering two things: first, is it safe to assume that any DAs will
have AES handles less than the current application? Second, assuming a DA
actually does care what menu id (as stored in buff[2]) the DA is assigned to
would my little guess be correct? Granted, there really is no reason I can
see why a DA should care if the menu id passed matches what it sees as being
correct, but considering how few correctly written DAs there are out there,
who knows.

Now for my opinion on the Copyright issue....naw, just kidding.

                                       Dan Wilga
-----------------------------------------------------------------------------
"You may think it's a long way down        Gribnif@UMASS.Bitnet
 the road to the chemist, but that's       Gribnif%UMASS.forsythe.stanford.EDU
 just peanuts to space."                        (methinks)
     -- Hitchhikers