Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RibbonUI.InvalidateControl does not work #191

Closed
Linhin opened this issue Jan 9, 2018 · 5 comments
Closed

RibbonUI.InvalidateControl does not work #191

Linhin opened this issue Jan 9, 2018 · 5 comments
Labels
Milestone

Comments

@Linhin
Copy link

Linhin commented Jan 9, 2018

I used RibbonUI.InvalidateControl to re-render the ribbon status, when ribbon update I use getEnabled callback to disable a control (in my example is an checkbox, set enable at begining). However, it does not work, the button is not be disabled after InvalidateControl called. I checked with only getEnable and it work perfectly, however InvalidateControl does not callback the getEnabled's function.
(This sample is created with Toolbox 1.5.0.0. Run with VS2015 and MS Office Excel 2010)

Here is code. Addin.cs

[COMAddin("TESTADDIN", "Test for Excel Addin", LoadBehavior.LoadAtStartup), ProgId("TESTADDIN.Addin"), Guid("4358F368-F127-425E-9BBE-7888D04A2CE2"), Codebase]
[CustomUI("RibbonUI.xml", true), CustomPane(typeof(MyTaskPane), "My TaskPane", true, PaneDockPosition.msoCTPDockPositionRight), RegistryLocation(RegistrySaveLocation.CurrentUser)]
public class Addin : Excel.Tools.COMAddin
{
    private bool checkEnable;
    public Addin()
    {
        this.OnStartupComplete += new OnStartupCompleteEventHandler(Addin_OnStartupComplete);
        this.OnDisconnection += new OnDisconnectionEventHandler(Addin_OnDisconnection);
        checkEnable = true;
    }



    public bool GetEnabled(Office.IRibbonControl control)
    {
        return checkEnable;
    }

    public void DisableButton_Click(Office.IRibbonControl control)
    {
        checkEnable = false;
        RibbonUI.InvalidateControl("MyCheckBox");
    }

    private void Addin_OnStartupComplete(ref Array custom)
    {
        Console.WriteLine("Addin started in Excel Version {0}", Application.Version);
    }

    private void Addin_OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom)
    {

    }
}

RibbonUI xml

    <group id="group1" label="TESTADDIN">
       <button id="aboutButton" label="About" imageMso="AdvertisePublishAs" size="large" onAction="AboutButton_Click" />
       <toggleButton id="tooglePaneVisibleButton" label="TaskPane" imageMso="CreateFormBlankForm" size="large" getPressed="TooglePaneVisibleButton_GetPressed" onAction="TooglePaneVisibleButton_Click" />
       <button id="DisableButton" label ="Disable" onAction="DisableButton_Click" size="large"/>
       <checkBox id="MyCheckBox" label="Test Check Box" getPressed="MyCheckBox_GetPressed" getEnabled="GetEnabled"/>
    </group>
@Linhin
Copy link
Author

Linhin commented Jan 13, 2018

After 4days seaching every related issues in Github, Codeplex and google but still can not solve this problem. I looked in to the source code of NetOffice 1.7.4.1 and found this in code of IRibbonUI.cs

public void Invalidated Control(string ControlID)
If(null == NativeRibbon)
NativeRibbon .InvalidateContol (ControlID)

This may be cause the problem InvalidateContol does not work.

Then I tried an old version of NetOffice which does not above code in the source. InvalidateContol works perfectly.

@jozefizso jozefizso added the bug label Jan 13, 2018
@jozefizso
Copy link
Member

Where in the source code have you found this?

@Linhin
Copy link
Author

Linhin commented Jan 14, 2018

This is location of the C# file which has above code: ".Net 4\Source\Office\NativeCaller\IRibbonUI.cs" in NetOffice 1.7.4.1 release (https://github.com/NetOfficeFw/NetOffice/releases/tag/v1.7.4.1)

@jozefizso
Copy link
Member

Reported as bug here: https://osdn.net/projects/netoffice/ticket/37880

jozefizso pushed a commit that referenced this issue Jan 14, 2018
jozefizso pushed a commit that referenced this issue Feb 23, 2018
…\NativeCaller\IRibbonUI.cs)

Fixes GitHub issue #191
Imported from NetOffice OSDN r31
https://osdn.net/projects/netoffice/scm/svn/commits/31
@jozefizso
Copy link
Member

Fixed in release v1.7.4.1 (Update 1)

@jozefizso jozefizso added this to the 1.7.4.1 milestone Nov 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants