2011-05-26 59 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

相關問題