mfc mdi .net toolbar

Posted on 2005-03-16
Medium Priority
Last Modified: 2013-11-25
I have the standard mfc toolbar created when you make a new mdi project. I added three new buttons using the resource editor. When i run the pgrogram they apper disabled. I tried to enable them with:

m_wndToolBar.SetButtonStyle(9, m_wndToolBar.GetButtonStyle(9) & ~TBBS_DISABLED);

and it works for a split second then reverts to being disabled.

Question by:as2003
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 48

Expert Comment

ID: 13562701
Toolbar button are automatically disabled if there is no commanf handler for them. Add handlers and they will be enanled.
To enable/disable toolbar buttons use ON_UPDATE_UI handlers.

Author Comment

ID: 13567769
Yeah, I found that in the documentation, but I don't know how to use/create/manipulate/find/etc ON_UPDATE_UI handlers
LVL 48

Accepted Solution

AlexFM earned 500 total points
ID: 13571894
Select class where you want to handle toolbar messages in the Class View . For example, this can be CMainFrame class. In the Properties window click Events tag. Find button ID in the list and expand it. Select  ON_UPDATE_UI item and select handler name from combobox. Fill handler:

void CMainFrame::OnUpdateMyCommand(CCmdUI *pCmdUI)
    pCmdUI->Enable(TRUE);   // instead of TRUE you can use some class member

See details in the CCmdUI class description.

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question