RibbonXml togglebutton OnAction没有找到回调函数
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RibbonXml togglebutton OnAction没有找到回调函数相关的知识,希望对你有一定的参考价值。
我发生了一个特殊的问题,尽管谷歌上网和修修补补,我还是无法解决这个问题。
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="OnHomeRibbonLoad">
<ribbon startFromScratch="true">
<tabs>
<tab id="tab_Home" label ="Home" visible="true">
<group id="grp_Navigate" label="Navigate" visible="true">
<button id="btn_Tasks" label="Tasks" onAction="OnAction" visible="true" imageMso="ViewAllProposals" size="large" />
<toggleButton id="btn_Parties" label="Parties" onAction="OnAction" getPressed="GetPressed" visible="true" imageMso="ViewAllProposals" size="large" />
<button id="btn_Memos" label="Memos" onAction="OnAction" visible="true" imageMso="AccessTableIssues" size="large" />
</group>
</tab>
</tabs>
</ribbon>
<backstage onShow="OnBackstageShow">
<button id="btn_Login" label="Login" insertAfterMso="TabPrint" visible="true" getEnabled="GetEnabled" onAction="OnAction" isDefinitive="true"/>
<tab id="tab_Settings" label="Settings" insertAfterMso="TabPrint" visible="true" getEnabled="GetEnabled" ></tab>
<tab id="tab_Welcome" label="Welcome" insertAfterMso="TabPrint" visible="true" > </tab>
<tab idMso="TabPrint" visible="false"/>
<button idMso="ApplicationOptionsDialog" visible="false"/>
</backstage>
我有上面的自定义UI xml,并将其中一个按钮更改为togglebutton(id =“btn_Parties”)。之前所有三个按钮都工作正常,但是在togglebutton之后找不到它的onAction回调函数。其他两个按钮触发正常,但单击togglebutton导致错误说...“Microsoft Access无法运行宏或回调函数'OnAction'。确保宏或函数存在并采取正确的参数”。
Public Sub OnHomeRibbonLoad(ribbon As IRibbonUI)
Set HomeRibbon = ribbon
End Sub
Public Sub OnAction(control As IRibbonControl)
Select Case control.ID
Case "btn_Tasks"
MsgBox "Load TaskView"
Case "btn_Parties"
MsgBox "Load PartyView"
Case "btn_Memos"
MsgBox "Load MemoView"
Case Else
Debug.Print "Missing case in OnAction: " & control.ID
End Select
End Sub
Public Sub GetPressed(control As IRibbonControl, ByRef returnedVal)
Select Case control.ID
Case "tbtn_Parties"
returnedVal = IsPartiesLoaded
Case Else
returnedVal = True
Debug.Print "Missing case in GetEnabled: " & control.ID
End Select
End Sub
togglebutton有什么特别的东西让它的OnAction事件与标准按钮不同吗?
如果有人能看到我出错的地方,那将非常感激。谢谢。
答案
onAction
控件的toggleButton
回调应如下所示:
- C#:
void OnAction(IRibbonControl control, bool pressed)
- VBA:
Sub OnAction(control As IRibbonControl, pressed As Boolean)
- C ++:
HRESULT OnAction([in] IRibbonControl *pControl, [in] VARIANT_BOOL *pvarfPressed)
- Visual Basic:
Sub OnAction(control As IRibbonControl, pressed As Boolean)
在以下系列文章中阅读有关Fluent UI(aka Ribbon UI)的更多信息:
- Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
- Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
- Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
以上是关于RibbonXml togglebutton OnAction没有找到回调函数的主要内容,如果未能解决你的问题,请参考以下文章
在 Flutter 中设置 ToggleButtons 之间的间隙