jcl@hpausla.HP.COM (Jeff Laing) (01/16/89)
A programmers desk accessory question; I have looked through Inside Mac, MacTutor and Chernicoff and haven't found an answer. What does a desk accessory have to do to close itself? I want to be able to have a desk acc which does NOT have a close box in the window (ok, I don't have a good reason, but why should that matter? In fact, I wanted the window to have a close BUTTON instead. Anyway...) If we assume I want a Close ... item on a desk accessories menu, then what should that code do? Its not as simple as calling the 'DrvrClose' routine in my code, nor is it 'CloseDeskAcc(myId)'.. Anyone got the answer?
parent@Apple.COM (Sean Parent) (01/17/89)
In article <2580008@hpausla.HP.COM>, jcl@hpausla.HP.COM (Jeff Laing) writes: > What does a desk accessory have to do to close itself? > > If we assume I want a Close ... item on a desk accessories menu, then what > should that code do? Its not as simple as calling the 'DrvrClose' routine > in my code, nor is it 'CloseDeskAcc(myId)'.. > > Anyone got the answer? Are you having trouble with calling CloseDeskAcc? You would have to be carefull to make sure that after calling CloseDeskAcc your code did nothing that could disturb memory sinse you are now operating out in either unlocked or purgable code. If CloseDeskAcc is moving the code befor you return (run your code with Heap Scrample turned on in MacsBug to test things out) then you could try to chain to CloseDeskAcc. To do this call GetTrapAddress to get the address of CloseDeskAcc push your parameter and the ruturn address of the routine you are in and jump to CloseDeskAcc. I hope these ideas help. Sean
jcl@hpausla.HP.COM (Jeff Laing) (01/19/89)
Sean Parent (parent@Apple.COM) writes in comp.sys.mac.programmer: > In article <2580008@hpausla.HP.COM>, jcl@hpausla.HP.COM (Jeff Laing) writes: > > What does a desk accessory have to do to close itself? > > > Are you having trouble with calling CloseDeskAcc? Tried it. Didnt seem to work. > You would have to be carefull > to make sure that after calling CloseDeskAcc your code did nothing that could > disturb memory sinse you are now operating out in either unlocked or purgable > code. If CloseDeskAcc is moving the code befor you return [ ... deleted ...] If I can't find Apple saying 'yes, call CloseDeskAcc' then I can't rely on it. I figured the problem might have been because I was calling 'CloseDeskAcc' last thing before returning, but I was still going back through LightSpeed C 3.01's DA glue, which might cause problems. Also, Suitcase probably wouldn't help either. Anyone think of something not involving CloseDeskAcc?
oster@dewey.soe.berkeley.edu (David Phillip Oster) (01/21/89)
CloseDeskAcc() works fine for me. If your desk accessory can't close itself by calling CloseDeskAcc() on its own refNum, then that is probably a symptom of some other bug in your code. (Try setting the clock flag in your own header before calling CloseDeskAcc. That should help keep it around until it has a chance to process its own close message. Note the section of the manual on keeping a d.a.'s data around even while it is closed.)