简体   繁体   中英

Temporarily make a control in MFC Ribbon inactive or disabled

I have a Ribbon UI for an MFC application. During certain processes, I would like to disable certain controls on the ribbon, so that the user generated events for those controls are no longer processed, until thee control is enabled back again. Does anyone know this could be done? I have looked through the API for the ribbon controls, but didnt see a SetEnable method or something similar.

CMFCRibbonComboBox* pMyComboBox = DYNAMIC_DOWNCAST(CMFCRibbonComboBox, m_wndRibbonBar.FindByID(ID_THIS));
// pMyComboBox->SetEnable(FALSE); // I am looking for something similar if it exists

MFC typically handles the updating of UI elements (eg. toolbar buttons, controls, etc.) via the ON_UPDATE_COMMAND_UI message handler.

ON_UPDATE_COMMAND_UI(id, memberFxn )

Basically, you code a handler for the control you want to enable/disable etc. When it gets called you will be passed a pointer to a CCmdUI object that will allow you to change the state of the control. Have look here for more info.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM