• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Detecting Frontmost Application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting Frontmost Application


  • Subject: Re: Detecting Frontmost Application
  • From: Matt Neuburg <email@hidden>
  • Date: Fri, 03 Feb 2006 16:07:12 -0800
  • Thread-topic: Detecting Frontmost Application

On Fri, 3 Feb 2006 15:39:02 -0500, William Henderson
<email@hidden> said:
>I know this topic has been covered before but also that things
>changed with Tiger.  According to http://www.cocoadev.com/index.pl?
>DetectingAppChange there is a way to do it via carbon, but is this
>the best way?  Do you have to use carbon do do this or can it be done
>without?

I think Carbon Events is the only way now. But it works great (in Tiger).
Here is code:

    EventTypeSpec eventType;
    eventType.eventClass = kEventClassApplication;
    eventType.eventKind  = kEventAppFrontSwitched;
    EventHandlerUPP handlerUPP = NewEventHandlerUPP(appSwitched);
    InstallApplicationEventHandler (handlerUPP, 1, &eventType, self, NULL);
    DisposeEventHandlerUPP(appSwitched);

And so:

pascal OSStatus appSwitched (EventHandlerCallRef nextHandler, EventRef
theEvent, void* userData) {
    ProcessSerialNumber newSerial;
    GetFrontProcess(&newSerial);
    // other stuff goes here
    return(CallNextEventHandler(nextHandler, theEvent));
}

m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: another NSAnimation crash
  • Next by Date: creating a preference window safari style
  • Previous by thread: Detecting Frontmost Application
  • Next by thread: How/where to catch QTMovieDidEndNotification
  • Index(es):
    • Date
    • Thread