VSTO:刷新Outlook2010功能区按钮控件标签

发布于 2024-11-07 19:39:53 字数 262 浏览 2 评论 0原文

我正在创建一个 Outlook2010 加载项,它将显示一个文件夹中有多少电子邮件,我们称之为 foo,它有许多子文件夹(在功能区加载期间,我聚合了 foo 及其子文件夹中的所有项目计数。我没有但是,如果用户将电子邮件从收件箱拖放到 foo 文件夹或其任何子文件夹中,反之亦然,则自定义功能区上的项目计数将不会反映

。但我没有让它启动,而且因为用户可以在 foo 下创建任意数量的子文件夹,我认为 beforeitemmove 事件不起作用。

有没有办法更新功能区控件(按钮)。

I'm creating a Outlook2010 add-in that will display how many email in a folder let's call it foo and it have many sub folders (During ribbon load, i have aggregated all the item count from foo and its sub folders. I have no problem with this part. However, if a user drag and drop a email from let's say Inbox into foo folder or any of its sub folder or vice versa then the item count on the custom ribbon will not reflect.

I tried to use folder beforeitemmove event but i wasn't get it to fire and also since user can create as many sub folder under foo as they want. I don't think beforeitemmove event will work.

Is there a way to update a ribbon control (button)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

童话里做英雄 2024-11-14 19:39:53

对于 Word,我刚刚发现,调用 Office::IRibbonUI::Invalidate() 会产生 GDI 对象泄漏。对于我的所有功能区按钮,都会调用相应的 getImage 回调。看来 Word 没有释放旧图像。

我还没有找到一种动态启用/禁用功能区按钮的方法。

For Word I just found, that calling Office::IRibbonUI::Invalidate() produces a GDI object leak. For all of my ribbon buttons, the corresponding getImage callback is invoked. It appears that Word does not free the old images.

I have not yet found a way for enabling / disabling ribbon buttons on the fly.

圈圈圆圆圈圈 2024-11-14 19:39:53

是的,作品无效。但是,当与按钮的 getImage 回调结合使用时,这将泄漏 GDI 对象(每个按钮每次刷新 2 个 GDI 对象)。

我刚刚得到工作代码:

使用全局加载图像回调:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnLoad" loadImage="OnLoadImage">

定义为:

STDMETHOD(OnLoadImage)(BSTR imageName, IPictureDisp** ppdispImage);

分别。

[
    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 对象泄漏。

Yes, invalidate works. But when used in combination with a getImage callback for a button, this will leak GDI objects (2 GDI objects per refresh per button).

I just got working code though:

Use a global load image callback:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnLoad" loadImage="OnLoadImage">

Defined as:

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);
};

It appears, that when the image is loaded via the global loadImage callback, there is no resource leak. But when the image is loaded by the getImage callback of a button, the new image is correctly loaded but I earn a GDI object leak.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文