2011-05-26 20 views

回答

1

如果停靠栏可见或未使用Carbon,则可以收到通知。我不知道有什么办法可可。

(我没有测试过这一点;从代码here的)

创建回调方法:

#import <Carbon/Carbon.h> 

static const EventTypeSpec appEvents[] = { 
    { kEventClassApplication, kEventAppSystemUIModeChanged } 
}; 

OSStatus DockChangedHandler(EventHandlerCallRef inCallRef, EventRef event, void *userData) { 
    OSStatus status = eventNotHandledErr; 
    switch(GetEventClass(event)) { 
     case kEventClassApplication: { 
      SystemUIMode *outMode; 
      SystemUIOptions *outOptions; 
      GetSystemUIMode(outMode, outOptions); 
      status = noErr; 
     } 
      break; 

     default: 
      return; 

    } 

    /*Insert whatever you want to do when you're notified of a dock change*/ 

    return status; 
} 

然后把这个地方要开始监听通知:

InstallApplicationEventHandler(NewEventHandlerUPP(DockChangedHandler), GetEventTypeCount(appEvents), appEvents, 0, NULL); 


进一步的信息:http://developer.apple.com/library/mac/#technotes/tn2002/tn2062.html

相关问题