-
Dynamic Toolbars
Hi guys,
I'm using VC6 SP5 with MFC to create my application. I have a Framewindow and a Toolbar. I can dynamically set the toolbars buttons. BUT: Obviously Framewindow/Toolbar pairs have some kind of automation that when the parent window has no command handler ( ON_COMMAND() ) of the toolbar buttons command ID, the toolbar button is disabled. What a funny idea. I can dynamically create buttons, but not their command handlers, as I need a unique function for each... who was the genius that thought this plan up ? If you have any clue what I'm talking about and/or any helpful hints, demo sources, tutorials, please share.
Because dynamic buttons are no fun if I don't have a chance to enable them.
I surfed the .net, but nothing really dynamic came up. I need it to be really dynamic, not cheats like create a hundred and hope that's the limit. I need it to be customizable in the code, not by the user of my app.
I know I can create the button. I can set the command handler ID. But If I have no hard-coded command handler, the framework will disable the button.
Tearing my hair out already... :confused:
[Edit: If you know how to do it in API only, your welcome... I will write the Toolbar class myself if I have to, I just need those *#&% dynamic stuff... ]
-
Just to keep you in the loop:
I dug up countless tutorials from the net. Not one did what I needed. Probably it's mentioned nowhere how to do it. So I scanned the MFC sourcecode for a solution and after 2 hours of searching, I turned up this:
PHP Code:
class CSAZToolBar : public CToolBar
{
virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHandler)
{
CToolBar::OnUpdateCmdUI( pTarget, FALSE );
}
};
If you overwrite the function that checks if there is a commandhandler and never disable any button, it works.
I'm still quite annoyed, this is something not that uncommon... and it's not even documented, because OnUpdateCmdUI is a method of CControlBar, CToolbars baseclass... *grrrrr*
Case closed. ;)