Click here to Skip to main content
Licence 
First Posted 15 Dec 1999
Views 123,846
Bookmarked 33 times

Using Hot Toolbar Buttons

By | 15 Dec 1999 | Article
Demonstrates how to add rollover buttons to your toolbar
  • Download demo project - 30 Kb
  • Sample Image - toolbar_hotbuttons.gif

    If you wanted to add hot toolbar buttons like the ones seen in internet explorer, it is pretty straight forward. This approach for will work for both Visual C++ 5 and 6, however you may want to read up on the enhancements to the toolbar class for VC 6.0.

    After your toolbar has been created in CMainFrame::OnCreate(), you will need to add the following code, this is assuming that you have two bitmap resources already created IDB_TOOLBAR_COLD for normal, and IDB_TOOLBAR_HOT for hot buttons:

    // Set up hot bar image lists.
    CImageList imageList;
    CBitmap    bitmap;
    
    // Create and set the normal toolbar image list.
    bitmap.LoadBitmap(IDB_TOOLBAR_COLD);
    imageList.Create(21, 20, ILC_COLORDDB|ILC_MASK, 13, 1);
    imageList.Add(&bitmap, RGB(255,0,255));
    m_hotToolBar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
    imageList.Detach();
    bitmap.Detach();
    
    // Create and set the hot toolbar image list.
    bitmap.LoadBitmap(IDB_TOOLBAR_HOT);
    imageList.Create(21, 20, ILC_COLORDDB|ILC_MASK, 13, 1);
    imageList.Add(&bitmap, RGB(255,0,255));
    m_hotToolBar.SendMessage(TB_SETHOTIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
    imageList.Detach();
    bitmap.Detach();
    

    The send message portion of the code has been wrapped into a CToolBarCtrl() function call for Visual C++ 6. If you will notice, I have used 24 bit color images with the toolbar shown here, so you are not limited to just 16 colors.

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here

    About the Author

    Kirk Stowell

    CEO
    Codejock Software
    United States United States

    Member



    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    You must Sign In to use this message board. (secure sign-in)
     
    Search this forum  
     FAQ
        Noise  Layout  Per page   
      Refresh
    QuestionHow to Dock the Hot Toolbar with the Main Toolbar Pinmembervikrant kpr10:01 11 May '07  
    GeneralExcellent PinmemberNeilDevlin5:54 5 Feb '05  
    How would I use this in place of the main toolbar?
    GeneralRe: Excellent PinmemberAlex Gibbs11:14 20 Mar '05  
    Generalvera neat ! PinmemberLi Zhaoming1:55 26 Nov '02  
    Generalvera good ! PinmemberChris maunder and nish2:46 19 May '02  
    GeneralHelp me Pinmembersreenivasulu9:22 2 Jan '01  
    GeneralLittle bug PinmemberSerrand23:52 23 Nov '00  
    GeneralGreat stuff - and here is the Disabled flag PinsussMark Grieve17:27 15 Mar '00  
    GeneralIt is vera poor!!!! PinsussTippler7:30 11 Mar '00  
    GeneralRe: It is vera poor!!!! PinsussCode Police19:51 18 Jun '00  
    GeneralRe: It is vera poor!!!! PinsussPhartPhace20:16 5 Sep '00  
    GeneralRe: It is vera poor!!!! PinmemberAnonymous19:10 15 May '01  
    QuestionWhat about in 256 colour mode ? PinsussChristian20:57 22 Jan '00  
    AnswerRe: What about in 256 colour mode ? PinsussTMan10:49 19 Jul '00  
    GeneralRe: What about in 256 colour mode ? PinsussDarkByte15:54 5 Sep '00  

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    Permalink | Advertise | Privacy | Mobile
    Web03 | 2.5.120528.1 | Last Updated 16 Dec 1999
    Article Copyright 1999 by Kirk Stowell
    Everything else Copyright © CodeProject, 1999-2012
    Terms of Use
    Layout: fixed | fluid