[comp.sys.mac.programmer] Determine the foreground application

pers@ifi.uio.no (Per Siljubergs}sen) (10/11/90)

Is there an easy way to determine the name (or some other ID)
of the foreground application (under MultiFinder)?

And what about the suspended applications?

I know that the global CurApName stores the current application name.
This dosn't help me much. This global returns suspended applications
while MF is doing minor switches.

Is this also considered Apple secrets?


---------------------------------------------------------------------
Per Siljubergsaasen, Dept. of Informatics, University of Oslo, Norway
pers@ifi.uio.no

dave@cmi.com (David Halonen) (10/17/90)

How can a background app come to the front, perform some task and then 
return the previous app to the front?  On a Mac.  Easy.

DrawMenuBar gets called as each app makes a major context switch.  Patch 
that sucker to keep track of who was on top before your app gets there and 
then do a OpenDeskApp on that name.  When DrawMenuBar is called, 
currAppName has the appropriate name filled in.  We've had great success 
with this.  Of course w/ System 7, a patch won't be necessary - I believe.

Now you get to work out the details of a meaningful interface.  Which 
means why can't the Notification Mgr be used?

David Halonen, Center for Machine Intelligence, Electronic Data Systems
Ann Arbor, MI (313) 995-0900
AppleLink: N0548  Internet: dave@cmi.com

llama@eleazar.dartmouth.edu (Joe Francis) (10/18/90)

In article <5180@etsu.CMI.COM> dave@cmi.com (David Halonen) writes:
>DrawMenuBar gets called as each app makes a major context switch.  Patch 
>that sucker to keep track of who was on top before your app gets there and 
>then do a OpenDeskApp on that name.  When DrawMenuBar is called, 
>currAppName has the appropriate name filled in.  We've had great success 
>with this.  Of course w/ System 7, a patch won't be necessary - I believe.

OK.  Let's say I'm a DrawMenuBar patch and I spy on curAppName.  What is the
easist way for me to go from this to finding the current app CREATOR TYPE
(or does the easiest way even use curAppName??).

-----------------------------------------------------------------------------
"Read My Lips: No Nude Texans!" - George Bush clearing up a misunderstanding

ech@cbnewsk.att.com (ned.horvath) (10/18/90)

From article <25162@dartvax.Dartmouth.EDU>, by llama@eleazar.dartmouth.edu (Joe Francis):
> In article <5180@etsu.CMI.COM> dave@cmi.com (David Halonen) writes:
>>DrawMenuBar gets called as each app makes a major context switch.  Patch 
>>that sucker to keep track of who was on top before your app gets there and 
>>then do a OpenDeskApp on that name.  When DrawMenuBar is called, 
>>currAppName has the appropriate name filled in.  We've had great success 
>>with this.  Of course w/ System 7, a patch won't be necessary - I believe.
> 
> OK.  Let's say I'm a DrawMenuBar patch and I spy on curAppName.  What is the
> easist way for me to go from this to finding the current app CREATOR TYPE
> (or does the easiest way even use curAppName??).
> 
> -----------------------------------------------------------------------------
> "Read My Lips: No Nude Texans!" - George Bush clearing up a misunderstanding

"...watch me for the changes, and try to keep up."
	-- M. McFly

You want to start with CurApRefNum (short integer at $900).  Make a call to
PBGetFCBInfo (IM IV-179) with ioRefnum = CurApRefNum and ioFCBIndx = 0.
Be sure to provide a Str255 buffer in ioNamePtr.

Now call PBGetFInfo (IM IV-148) with the ioNamePtr and ioVRefNum you just
got, and ioFVersNum and ioFDirIndex set to 0.

At completion, examine the ioFlFndrInfo; its format is described on
IM IV-104.  The first two longwords are the type and creator.

Why is this kind of thing so hard...?

=Ned Horvath=