Vivek Kumar
Vivek Kumar

Reputation: 5040

Updating toolbar button state MFC

I have a dialog in MFC application, which is having menu-bar. Now I have created a toolbar in that dialog using the same command ID which is in the menu-bar.

I use to update the menu-item's state and makes it enable/disable as per some check in ON_UPDATE_COMMAND_UI, When I clicks on the menu. But for toolbar I didn't gets these calls to update it's state, If it should be enabled/disabled.

Moreover I didn't have any notification when the test fails and I to disable the item.

Is there some alternative for doing this?

Thanks

call to ON_UPDATE_COMMAND_UI is only coming when I click on the toolbar button.

Upvotes: 2

Views: 6034

Answers (1)

Albertino80
Albertino80

Reputation: 1093

Use MFC in a dialog can be frustrating.

I suggest you disable the toolbar button directly when changing state to the variable that will enable / disable the menu:

void CtestDlg::OnBnClickedButton_DisableSomeControls()
{
command_menu_1 = !command_menu_1;
m_ToolBar.GetToolBarCtrl().EnableButton(ID_COMMAND_TEST, command_menu_1);
}

is not very elegant, but it works!

Upvotes: 1

Related Questions