是的,無效的作品。但是,當與按鈕的getImage回調結合使用時,這會泄漏GDI對象(每個按鈕每次刷新2個GDI對象)。
我剛剛工作,雖然代碼:
使用全局負載圖像回調:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnLoad" loadImage="OnLoadImage">
定義爲:
STDMETHOD(OnLoadImage)(BSTR imageName,IPictureDisp ** ppdispImage);
resp。
[
object,
uuid(CE895442-9981-4315-AA85-4B9A5C7739D8),
dual,
nonextensible,
helpstring("IRibbonCallback Interface"),
pointer_default(unique)
]
interface IRibbonCallback : IDispatch{
[id(0x00000001),helpstring("OnLoad Callback")] HRESULT OnLoad([in]IDispatch* pRibbonUIDispatch);
[id(0x00000002),helpstring("Button Callback")] HRESULT RibbonButtonClicked([in]IDispatch* pRibbon);
[id(0x00000003),helpstring("ToggleButton Callback")] HRESULT RibbonToggleButtonClicked([in]IDispatch* pRibbon,[in] VARIANT_BOOL *pvarfPressed);
[id(0x00000004),helpstring("GetSmallCustomImage Callback")] HRESULT GetSmallCustomImage([in]IDispatch* pRibbon, [out, retval] IPictureDisp** ppdispImage);
[id(0x00000005),helpstring("GetLargeCustomImage Callback")] HRESULT GetLargeCustomImage([in]IDispatch* pRibbon, [out, retval] IPictureDisp** ppdispImage);
[id(0x00000006),helpstring("GetLabel Callback")] HRESULT GetCustomLabel([in]IDispatch* pRibbon, [out, retval] BSTR* pbstrLabel);
[id(0x00000007),helpstring("ShowLabel Callback")] HRESULT GetShowLabel ([in]IDispatch* pRibbon, [out, retval] VARIANT_BOOL *pvarShowLabel);
[id(0x00000008),helpstring("GetEnabled Callback")] HRESULT GetEnabled ([in]IDispatch* pRibbon, [out, retval] VARIANT_BOOL *pvarEnabled);
[id(0x00000009),helpstring("GetVisible Callback")] HRESULT GetVisible ([in]IDispatch* pRibbon, [out, retval] VARIANT_BOOL *pvarVisible);
[id(0x0000000A),helpstring("GetItemPressed Callback")] HRESULT GetItemPressed ([in]IDispatch* pRibbon, [out, retval] VARIANT_BOOL *pvarChecked);
[id(0x0000000B),helpstring("GetScreentip Callback")] HRESULT GetScreentip ([in]IDispatch* pRibbon, [out, retval] BSTR *pbstrScreentip);
[id(0x0000000C),helpstring("GetGroupImage Callback")] HRESULT GetGroupImage([in]IDispatch* pRibbon, [out, retval] IPictureDisp** ppdispImage);
[id(0x0000000D),helpstring("OnLoadImage Callback")] HRESULT OnLoadImage([in]BSTR imageName, [out, retval] IPictureDisp** ppdispImage);
};
看起來,當圖像通過全局loadImage回調加載時,沒有資源泄漏。但是當圖像通過按鈕的getImage回調加載時,新圖像被正確加載,但是我獲得了GDI對象泄漏。
它確實工作:) – 2012-11-15 09:15:42