Dynamic Toolbars

This is a discussion on Dynamic Toolbars within the Windows Programming forums, part of the Platform Specific Boards category; Hi guys, I'm using VC6 SP5 with MFC to create my application. I have a Framewindow and a Toolbar. I ...

  1. #1
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139

    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...

    [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... ]
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    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(CFrameWndpTargetBOOL bDisableIfNoHandler)
       {
          
    CToolBar::OnUpdateCmdUIpTargetFALSE ); 
       }
    }; 
    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.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. Replies: 4
    Last Post: 11-02-2006, 10:41 AM
  3. Identify dynamic IP address of network device
    By BobS0327 in forum Tech Board
    Replies: 2
    Last Post: 02-21-2006, 12:49 PM
  4. operator overloading and dynamic memory program
    By jlmac2001 in forum C++ Programming
    Replies: 3
    Last Post: 04-06-2003, 11:51 PM
  5. Dynamic memory confusion
    By ripper079 in forum C++ Programming
    Replies: 5
    Last Post: 11-04-2002, 05:15 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21