I have the following (as part of my ribbon XML)
CODE
<group id="SeatDtls1" label="Seat details" getVisible="SetVisible">
<button id="fSeatdtls" size="large" screentip="Show seat booking information" getLabel="onGetLabel" imageMso="FileDocumentInspect" onAction="rbnAct" />
</group>
<button id="fSeatdtls" size="large" screentip="Show seat booking information" getLabel="onGetLabel" imageMso="FileDocumentInspect" onAction="rbnAct" />
</group>
With the following callback (part):
CODE
Public Sub onGetLabel(cntrl As IRibbonControl, ByRef Label)
On Error GoTo err_proc
Dim strLabel As String
Set srcForm = Forms.frmbookings
Select Case cntrl.ID
' Case ....
Case "fSeatDtls"
MsgBox cntrl.ID 'Test purposes
Label = "Seat " & srcForm.SeatNo.Caption & " details"
End Select
exit_proc:
Exit Sub
err_proc:
MsgBox err.Description
Resume exit_proc
End Sub
On Error GoTo err_proc
Dim strLabel As String
Set srcForm = Forms.frmbookings
Select Case cntrl.ID
' Case ....
Case "fSeatDtls"
MsgBox cntrl.ID 'Test purposes
Label = "Seat " & srcForm.SeatNo.Caption & " details"
End Select
exit_proc:
Exit Sub
err_proc:
MsgBox err.Description
Resume exit_proc
End Sub
elsewhere in my code I have:
CODE
If Not gobjRibMain Is Nothing Then
gobjRibMain.InvalidateControl "fSeatDtls"
MsgBox "Inval " & "fSeatDtls" 'Test purposes
End If
gobjRibMain.InvalidateControl "fSeatDtls"
MsgBox "Inval " & "fSeatDtls" 'Test purposes
End If
On start up the button XML correctly calls the onGetLabel callback and the correct label is displayed on the button
When appropriate the invalidate control command is run, however the onGetLabel callback is NOT triggered.
Does the getLabel callback only get triggered on ribbon load and not get called when a ribbon button control is invalidated?
(NB I have not tried using the invalidatecontrol on a button to update the button caption before,
The onAction callback works correctly and the same code works for a label control.
I have tried a C&R and decompile with no effect.)
TIA
Edit:
Well, I've not solved the problem! but I have used the same basic structure to change the text on the group:
XML:
CODE
<group id="SeatDtls1" getLabel="onGetLabel" getVisible="SetVisible">
<button id="fSeatdtls" label="Seat details" size="large" screentip="Show seat booking information" getVisible="SetVisible" imageMso="FileDocumentInspect" onAction="rbnAct" />
</group>
<button id="fSeatdtls" label="Seat details" size="large" screentip="Show seat booking information" getVisible="SetVisible" imageMso="FileDocumentInspect" onAction="rbnAct" />
</group>
Invalidate code:
CODE
If Not gobjRibMain Is Nothing Then
gobjRibMain.InvalidateControl "SeatDtls1"
End If
gobjRibMain.InvalidateControl "SeatDtls1"
End If
Callback code
CODE
Public Sub onGetLabel(cntrl As IRibbonControl, ByRef Label)
On Error GoTo err_proc
Set srcForm = Forms.frmbookings
Select Case cntrl.ID
' Case ...
Case "SeatDtls1"
Label = "Seat " & srcForm.SeatNo.Caption
End Select
exit_proc:
Exit Sub
err_proc:
MsgBox err.Description
Resume exit_proc
End Sub
On Error GoTo err_proc
Set srcForm = Forms.frmbookings
Select Case cntrl.ID
' Case ...
Case "SeatDtls1"
Label = "Seat " & srcForm.SeatNo.Caption
End Select
exit_proc:
Exit Sub
err_proc:
MsgBox err.Description
Resume exit_proc
End Sub
The XML and code are identical except that the callback/text changes are on a ribbon group (and work fine)
But why not the button?
The code now indicates what I want, but has the effect of changing the width of the ribbon group when the text changes, not that it matters much just looks a bit odd.