- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Disabling/enabling of control definition not working
In our addon (developed in c++), trying to disable/enable few control definitions and works for most of controls. Disabling of control definition - "MoldCreateMoldDesign" is not working and remain enabled in ribbon.
Display name in ribbon: Create Mold Design in Environment menu.
Executing below code in document activate event.
c++ code:
CComPtr<CommandManager> pCommandManager;
HRESULT hr = pApplication->get_CommandManager(&pCommandManager);
ControlDefinitionsPtr defs = pCommandManager->GetControlDefinitions();
long defCount = 1;
CComPtr<ControlDefinition> pDef;
//Iterate through the controls
for (; (hr = defs->get_Item(CComVariant(defCount), &pDef)) == S_OK; pDef.Release())
{
++defCount;
std::wstring iname = pDef->GetInternalName();
if (iname == L"MoldCreateMoldDesign")
{
pDef->put_Enabled(VARIANT_FALSE);
break;
}
}
Also checked in vba code and disabling properly.
vba code:
Sub DiableCommandName()
Dim oCommandMgr As CommandManager
Set oCommandMgr = ThisApplication.CommandManager
Dim oControlDefs As ControlDefinitions
Set oControlDefs = oCommandMgr.ControlDefinitions
Dim oControlDef As ControlDefinition
'Iterate through the controls.
For Each oControlDef In oControlDefs
If oControlDef.InternalName = "MoldCreateMoldDesign" Then
oControlDef.Enabled = False
End If
Next
End Sub
Why same logic not working in c++ addon?
what is the solution to disable/enable "MoldCreateMoldDesign" control?.