Sign in to follow this  
Coluna

Toolbar problem in MFC

Recommended Posts

Hello; Im having a stupid bug here: when i add a new button to the toolbar, it gets DISABLED (grayed and no clik allowed), even if i set TBBUTTONINFO.fsState with enabled or anything else...strange is that the toolbar has about 10 buttons, and only with the new ones the problem is ocurring...but if i set the ID of a new button with an old ID, it works....does anybody knows what can be happening? thanks!!

Share this post


Link to post
Share on other sites
You have to map an event handling function for that button. If there isn't any action associated with a given button, then it's disabled.
You should have something like :


BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_CREATE()
ON_WM_CLOSE()
// ....
END_MESSAGE_MAP()



somewhere in your code. Just add


ON_COMMAND(NEW_BUTTON_ID, OnNewButtonPressed)


where OnNewButtonPressed() is a function that will be called when you click on your button.

Share this post


Link to post
Share on other sites
Ughhh...i did that using class wizard...and it starts working..i didnt know i had to have a ONCLICK event to get it enabled!! thanks for the tip!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this