CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 1999
    Posts
    66

    How to merge toolbars?

    Hi all,

    I have a „Multiple top-level documents“ application, which should show different file types: pictures, music, etc. Now I have a common tool bar with action available for all file types like “open”, “about” and some other toolbars, depending on what kind of files I open, something like:
    IDR_MAINFRAME TOOLBAR 16, 15
    BEGIN
    BUTTON ID_FILE_OPEN
    BUTTON ID_APP_ABOUT
    END

    IDR_PICTURE_TOOLBAR TOOLBAR 16, 15
    BEGIN
    BUTTON ID_ROTATE_PICTURE
    BUTTON ID_ZOOM_PICTURE
    BUTTON ID_BLA_PICTURE
    END

    IDR_MUSIC_TOOLBAR TOOLBAR 16, 15
    BEGIN
    BUTTON ID_STOP
    BUTTON ID_PREVIOUS
    BUTTON ID_PLAY
    BUTTON ID_NEXT
    END
    Now I want to merge some of them, better say I want to insert one between 2 special buttons (in this case between open and about), so if I open a picture file I want to have a result like:

    IDR_PICTURE_RES_TOOLBAR TOOLBAR 16, 15
    BEGIN
    BUTTON ID_FILE_OPEN
    SEPARATOR
    BUTTON ID_ROTATE_PICTURE
    BUTTON ID_ZOOM_PICTURE
    BUTTON ID_BLA_PICTURE
    SEPARATOR
    BUTTON ID_APP_ABOUT
    END

    Or a music file:

    IDR_MUSIC_TOOLBAR TOOLBAR 16, 15
    BEGIN
    BUTTON ID_FILE_OPEN
    SEPARATOR
    BUTTON ID_STOP
    BUTTON ID_PREVIOUS
    BUTTON ID_PLAY
    BUTTON ID_NEXT
    SEPARATOR
    BUTTON ID_APP_ABOUT
    END

    Knows somebody if this is possible or not? Maybe knows somebody a good sample? Thank you in advance!

    Best regards,
    Emil

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: How to merge toolbars?

    Open these toolbars in the resource editor, drag-n-drop (copy) buttons from one to another.
    Then you should hide/show these buttons depending on the current View (use CToolbarCtrl::HideButton method to do it).

  3. #3
    Join Date
    Sep 1999
    Posts
    66

    Re: How to merge toolbars?

    Thank you Victor for your answer, but this is not an option. Or let’s say it’s not an elegant one. You must imagine a lot of toolbar buttons for each file type (many types not only picture and music). It will be very difficult to manage such a big toolbar. I want to handle this separately. Also I could handle all of them as separate very small toolbars and put them together, but I look for a method to this (merging/insert NOT disabling) at the runtime.
    Ciao,
    Emil

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: How to merge toolbars?

    1. There is no problem to show any number of the toolbars sowing/hiding some of their buttons.
    2. There is no function for "merging" toolbars. You however can add/insert any new buttons to any of your toolbars. Have a look at:
    CToolBarCtrl::GetButton
    CToolBarCtrl::AddButtons
    CToolBarCtrl::InsertButton
    CToolBarCtrl::AddBitmap
    CToolBarCtrl::AddStrings
    CToolBarCtrl::AddString

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured