每个单独打开的控件功能区按钮 window
Control ribbon buttons for each opened window separately
我正在编写一个 Outlook 加载项,它有自己的功能区,按钮在 xml 清单中定义。除了主要的 Outlook window(资源管理器)之外,还可以打开单独的 windows(检查器),它们都具有相同的功能区。我想独立控制功能区按钮的属性。但是在我的 getPressed
按钮处理程序中,我总是得到相同的功能区对象。 OnRibbonLoad
总是只调用一次。所以,我想假设地看到,丝带的数量与那里的检查员 (+ explorer) 的数量一样多。在行为方面:想象一个浏览器显示一封电子邮件,还有一个检查员在其中显示另一封电子邮件。两个 windows 都有相同的功能区,但我希望能够在每个 window 中独立地 enable/disable 按钮。
这是我的清单:
<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;
}
当触发控件回调(onAction、getImage、getEnabled 等)时,您将收到 IRibbonControl
作为参数。 IRibbonControl.Context
属性 将是 Explorer
或 Inspector
对象,从那里您可以到达 Inspector.CurrentItem
或 Explorer.Selection
以对 per-item基础.
我正在编写一个 Outlook 加载项,它有自己的功能区,按钮在 xml 清单中定义。除了主要的 Outlook window(资源管理器)之外,还可以打开单独的 windows(检查器),它们都具有相同的功能区。我想独立控制功能区按钮的属性。但是在我的 getPressed
按钮处理程序中,我总是得到相同的功能区对象。 OnRibbonLoad
总是只调用一次。所以,我想假设地看到,丝带的数量与那里的检查员 (+ explorer) 的数量一样多。在行为方面:想象一个浏览器显示一封电子邮件,还有一个检查员在其中显示另一封电子邮件。两个 windows 都有相同的功能区,但我希望能够在每个 window 中独立地 enable/disable 按钮。
这是我的清单:
<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;
}
当触发控件回调(onAction、getImage、getEnabled 等)时,您将收到 IRibbonControl
作为参数。 IRibbonControl.Context
属性 将是 Explorer
或 Inspector
对象,从那里您可以到达 Inspector.CurrentItem
或 Explorer.Selection
以对 per-item基础.