[comp.sys.mac.programmer] A suicidal desk accessory

freek@uva.UUCP (Freek Wiedijk) (05/28/88)

I've seen the following question before on the net, but I still don't know
the answer:

What is the proper way for my desk accessory to commit suicide, i.e. to close
itself and vanish without leaving a trace?
(i)   To call my own Close routine won't help much, because the system won't
      know I'm doing it, and the DA will stay active.
(ii)  However if I call CloseDeskAcc from within the DA code, that code won't
      be there to return to, after CloseDeskAcc is finished (or will it?).

Is it possible that I am mistaken, and that the only way to terminate a DA is
by closing it with the close box of its window, or with Close from the File
menu (in both cases CloseDeskAcc will be called from outside the DA)?

The correct answer to this question (a reference to the proper tech. note?)
will be appreciated. Can Larry Rosenstein send one of his very clear replies?

-- 
Freek Wiedijk  <the pistol major>                  UUCP: uunet!mcvax!uva!freek
#P:+/ = #+/P?*+/ = i<<*+/P?*+/ = +/i<<**P?*+/ = +/(i<<*P?)*+/ = +/+/(i<<*P?)**

leonardr@uxe.cso.uiuc.edu (06/01/88)

freek@uva.UUCP(Freek Wiedijk) writes in comp.sys.mac.programmer

>What is the proper way for my desk accessory to commit suicide, i.e. to close
>itself and vanish without leaving a trace?
>(i)   To call my own Close routine won't help much, because the system won't
>      know I'm doing it, and the DA will stay active.
>(ii)  However if I call CloseDeskAcc from within the DA code, that code won't
>      be there to return to, after CloseDeskAcc is finished (or will it?).
>
>Is it possible that I am mistaken, and that the only way to terminate a DA is
>by closing it with the close box of its window, or with Close from the File
>menu (in both cases CloseDeskAcc will be called from outside the DA)?
>
	Well, I don't know if it is the _CORRECT_ answer or not, but SigmaEdit (DA)
uses a CloseDeskAcc on itself when it gets a Cmd-Q ( Not menu item, yet ) and
things work just fine.  Hope that helps...


+---------------------------------+-----------------------------------+
+                                 +  Any thing I say may be taken as  +
+   Leonard Rosenthol             +  fact, then again you might decide+
+   President, LazerWare, inc.    +  that it really isn't, so you     +
+                                 +  never know, do you??             +
+   leonardr@uxe.cso.uiuc.edu     +                                   +
+   GEnie:  MACgician             +  AppleLink:D0025                  +
+   Delphi: MACgician             +                                   +
+                                 +                                   +
+---------------------------------+-----------------------------------+

shane@pepe.cc.umich.edu (Shane Looker) (06/18/88)

In article <226000016@uxe.cso.uiuc.edu> leonardr@uxe.cso.uiuc.edu writes:
!
!freek@uva.UUCP(Freek Wiedijk) writes in comp.sys.mac.programmer
!
!>What is the proper way for my desk accessory to commit suicide, i.e. to close
!>itself and vanish without leaving a trace?
!>(i)   To call my own Close routine won't help much, because the system won't
!>      know I'm doing it, and the DA will stay active.
!>(ii)  However if I call CloseDeskAcc from within the DA code, that code won't
!>      be there to return to, after CloseDeskAcc is finished (or will it?).
!>
!	Well, I don't know if it is the _CORRECT_ answer or not, but SigmaEdit (DA)
!uses a CloseDeskAcc on itself when it gets a Cmd-Q ( Not menu item, yet ) and
!things work just fine.  Hope that helps...
!

The line of code I use for this is:
	  CloseDriver(dce->dCtlRefNum);

	  dce is the Device Control Entry data structure.

I do this if the DA can't open, Close is selected from the DA Menu, or a
Goodbye Kiss is sent to the DA.  No problems with this.  (I think it is the
correct way to do it.)

!+   Leonard Rosenthol             +  fact, then again you might decide+
!+   President, LazerWare, inc.    +  that it really isn't, so you     +
(Strange, I saw you before I saw this, Leonard.  I want my Usenet TV!)



Shane Looker
shane@pepe.cc.umich.edu 
uunet!umix!pepe.cc.umich.edu!shane
Looker@um.cc.umich.edu