Jul 97 - Tips
Volume Number: 13 (1997)
Issue Number: 7
Column Tag: Tips & Tidbits
Jul 97 - Tips & Tidbits
by Steve Sisak
In article <19970223210019110631@stcc010.ulaval.ca>, <cbrunet@geocities.com> (Charles Brunet) wrote:
When I call FSpDelete in my application, the document is not always deleted from the Finder. Sometime, I must create an other document with the same name to erase it. Is it possible to ask Finder to forget this file right now?
I have the same problem when I create a document. It take some time before it appear in the Finder.
How to update the informations in the Finder? If you have a scriptable finder, you can send it an update event. Here is a snippet from an (as of yet) unreleased piece of software:
OSErr
ICTyper::SendFinderAEUpdate(FSSpec &inFile)
{
OSErr err = noErr;
AEDesc processDesc;
AppleEvent ae, aeReply;
ae.descriptorType = aeReply.descriptorType = processDesc.descriptorType
= typeNull;
ae.dataHandle = aeReply.dataHandle = processDesc.dataHandle = nil;
Try_ {
DescType finderType = 'MACS';
err =
::AECreateDesc(typeApplSignature,&finderType,sizeof(DescType),&processDesc);
FailOSErr_(err);
err = ::AECreateAppleEvent('fndr', 'fupd',&processDesc,
kAutoGenerateReturnID,kAnyTransactionID,&ae);
FailOSErr_(err);
err =
::AEPutParamPtr(&ae,keyDirectObject,typeFSS,&inFile,sizeof(inFile));
FailOSErr_(err);
err = ::AESend(&ae,&aeReply, kAENoReply | kAENeverInteract,
kAENormalPriority,
kAEDefaultTimeout,nil,nil);
FailOSErr_(err);
}
Catch_(catchErr) {err = catchErr;} EndCatch_
if (processDesc.descriptorType != typeNull) :AEDisposeDesc(&processDesc);
if (ae.descriptorType != typeNull) ::AEDisposeDesc(&ae);
if (aeReply.descriptorType != typeNull) :AEDisposeDesc(&aeReply);
return err;
}
Jim Correia
pmth02jc@umassd.edu
Screen Shots the Gnarly Way
One thing you can't do on the standard MacOS today is take a screen snapshot with a menu being displayed (or indeed, with the mouse down). There are lots of third-party solutions to this, but in fact there is a way to get such a screen snapshot, by installing no additional software other than MacsBug. And since all readers of this magazine already have MacsBug installed (well, don't you?), that means you can indeed take screen snapshots with menus displayed on your Mac!
CAUTION: this technique can crash your machine, or have other unexpected consequences. Perhaps you should look on it as Another Fun Thing to Do With MacsBug, to show off to your fellow geeks at parties, rather than as a serious technique for regular use.
First of all, type cmd-shift-3 to invoke the standard screen snapshot FKEY. This is purely to make sure the FKEY code is loaded in memory; you can throw away the PICT file it creates at this point. Next, hold down the mouse button to display the menu that you want to take a snapshot of. While still holding the button down, use your other hand to press the interrupt button (or key sequence) to break into MacsBug. Once the MacsBug screen appears, you can release the mouse button.
Use the "hx" command, if necessary, to switch to the system heap. Now use the command
hd FKEY
to find out where the code for FKEY 3 is loaded. You will see a display that looks something like this:
Displaying the System heap at 00002000
Start Length Tag Mstr Ptr Lock Prg Type ID File Name
0038F52C 0000046C+08 R 0019DA1C P FKEY 0003 0002
#1 block listed, which uses #1152 bytes, storing #1132 bytes
(If you see more than one FKEY loaded, the one you want will have "0003" under the ID column.) Make a note of the hexadecimal number under "Start" -- that is the start address of the FKEY code. Next, enter the following commands:
sp := sp-4
sl sp pc
pc := xxxxxxxx
(replace the "xxxxxxxx" with the start address of FKEY 3 you obtained before.)
Finally, enter the command "g" to resume execution. You should hear the click of the snapshot being taken, followed by the disappearance of the menu that was being displayed. But if you have a look at the resulting snapshot PICT file, you will see that it shows the menu!
Assuming your machine stays up that long (hee-hee)...
Lawrence D'Oliveiro
LDO@waikato.ac.nz