A Mac callback function issue
Mac 上的 callback function ,最好用 UPP 的方式 ,
以方便以後移除 callback function .
不然用 InstallXXXHandler 根本無法移除 callback function ,
會有後遺症 .
這問題在 fax driver 上發生過 .
用InstallXXXHandler 安裝 callback function ,
攔截 print button event 以檢查 fax number 是不是空的 .
但是 ,
要是系統有多個 printer drivers ,在使用者轉換 driver 時 ,
printer button 的 callback function 會遺留而造成不可預知的結果 .
==================================================
05/01/2008 更正 ,
要真正移除 event handler ,
要呼叫 OSStatus RemoveEventHandler(EventHandlerRef inHandlerRef);
inHandlerRef 是由
OSStatusInstallEventHandler(EventTargetRef inTarget,EventHandlerUPP inHandler,
UInt32 inNumTypes,const EventTypeSpec *inList,
void *inUserData,EventHandlerRef *outRef);
最後的一個參數所產生
留言