【发布时间】:2020-08-27 07:37:02
【问题描述】:
我正在编写一个 Outlook 加载项,它有自己的功能区,其中包含在 xml 清单中定义的按钮。除了主 Outlook 窗口(资源管理器)外,还可以打开单独的窗口(检查器),它们都具有相同的功能区。我想独立控制功能区按钮的属性。但在我的getPressed 按钮处理程序中,我总是得到相同的功能区对象。而OnRibbonLoad 总是只被调用一次。所以,我想假设看到的是,那里的检查员(+资源管理器)的数量与丝带的数量一样多。在行为方面:假设一个浏览器显示了一封电子邮件,并且还有一个检查员在其中包含另一封电子邮件。两个窗口都有相同的功能区,但我希望能够独立启用/禁用每个窗口中的按钮。
这是我的清单:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnRibbonLoad">
<ribbon>
<tabs>
<tab idMso="%1">
<group id="addin_group" label="Title" getImage="GetAddinGroupImage">
<toggleButton id="addin-enable-toggle"
size="large"
getLabel="GetAddinEnabledStatusLabel"
onAction="OnAddinToggled"
getPressed="GetAddinEnabled"
getImage="GetAddinEnabledImage"
getEnabled="GetAddinTogglePermission"
/>
<button id="ButtonSetting"
getImage="GetSettingButtonImage"
size="large"
label="Configure"
screentip="Configure"
supertip="Opens the configuration dialog."
onAction="OnSettingButtonClicked"
getEnabled="GetAddinValid"
/>
<button id="ButtonRefresh"
getImage="GetRefreshButtonImage"
size="large"
label="Refresh"
screentip="Refresh scan result"
supertip="Remeasure the threat level of the current item."
onAction="OnRefreshMailResults"
getEnabled="GetAddinValid"
/>
<button id="ButtonReport"
getImage="GetButtonReportImage"
size="large"
label="Report"
screentip="Report mail"
supertip="Reports the opened mail."
onAction="OnButtonReportPressed"
getEnabled="GetEmailReportingEnabled"
/>
<button id="ButtonUnlock"
getImage="GetButtonUnlockImage"
size="large"
label="Unlock"
screentip="Unlock mail"
supertip="Unlocks the opened mail."
onAction="OnButtonUnlockPressed"
getEnabled="GetEmailUnlockingEnabled"
/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
<tab idMso="%1"> 中的%1 被 TabReadMessage 或 TabMail 替换,具体取决于我在 IRibbonExtensibility::getCustomUI 函数中获得的 ribbonId 值:
//IRibbonExtensibility Methods
STDMETHODIMP CConnect::GetCustomUI(BSTR RibbonID, BSTR *RibbonXml)
{
if(!RibbonXml)
{
return E_POINTER;
}
//Get the ID of the ribbon that a custom UI is being requested for
QString ribbonIdStr = BSTR2QString(RibbonID);
static QMap<QString, QString> ribbonViews;
if(ribbonViews.isEmpty()) { //initialize
ribbonViews["Microsoft.Outlook.Mail.Read"] = "TabReadMessage";
ribbonViews["Microsoft.Outlook.Explorer"] = "TabMail";
}
if(ribbonViews.contains(ribbonIdStr)) {
*RibbonXml = XmlResource2ComBSTR(ASSET_RIBBON_MANIFEST, &ribbonViews[ribbonIdStr]);
}
return S_OK;
}
【问题讨论】:
标签: vsto outlook-addin