Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Disabling/enabling of control definition not working

prakash.muthu
Advocate

Disabling/enabling of control definition not working

prakash.muthu
Advocate
Advocate
Hi,
 

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?.

0 Likes
Reply
299 Views
2 Replies
Replies (2)

JelteDeJong
Mentor
Mentor

I have no experience with C++. But have you seen this site by @oransen . There is a lot of information there. Maybe you can find an answer there.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes

prakash.muthu
Advocate
Advocate

Checked  this  site and no solution found. 

0 Likes