Extended Multi Size Multi Color Toolbar!

This package differ from other package from the point of view that it support small or large icon. Text or no text and 16 or 256 colors. You can use icon or bitmap to create the toolbar.

It is using the explorer toolbar, so you need at least explorer 3. It's easy and nice to use.

This is a sample on how to use it. For further information, take a look at the sample application zip files.


    // This is a toolbar using bitmap resource file.
    if (!m_stdToolBar.Create(this) ||
        !m_stdToolBar.LoadToolBar(IDR_MAINFRAME))
    {
        TRACE0("Failed to create toolbar\n");
        return -1;      // fail to create
    }

    m_stdToolBar.SetBitmap( IBD_SM,         COOBmpToolBar::SmallHot,         RGB( 30, 179, 223 ) );
    m_stdToolBar.SetBitmap( IDB_SM_BW,      COOBmpToolBar::SmallStandard,   RGB( 30, 179, 223 ) );
    m_stdToolBar.SetBitmap( IDB_SM_DB,      COOBmpToolBar::SmallDisable,     RGB( 172, 172, 172 ) );
    m_stdToolBar.SetBitmap( IDB_LG,         COOBmpToolBar::LargeHot,         RGB( 33, 231, 222 ) );
    m_stdToolBar.SetBitmap( IDB_LG_BW,      COOBmpToolBar::LargeStandard,   RGB( 33, 231, 222 ) );
    m_stdToolBar.SetBitmap( IDB_LG_DB,      COOBmpToolBar::LargeDisable,     RGB( 170, 170, 170 ) );
    m_stdToolBar.SetBitmap( IDB_SM_16,      COOBmpToolBar::SmallHot,         RGB( 0, 255, 255 ), false );
    m_stdToolBar.SetBitmap( IDB_SM_BW_16,   COOBmpToolBar::SmallStandard,   RGB( 0, 255, 255 ), false );
    m_stdToolBar.SetBitmap( IDB_SM_DB_16,   COOBmpToolBar::SmallDisable,     RGB( 192, 192, 192 ), false );
    m_stdToolBar.SetBitmap( IDB_LG_16,      COOBmpToolBar::LargeHot,         RGB( 0, 255, 255 ), false );
    m_stdToolBar.SetBitmap( IDB_LG_BW_16,   COOBmpToolBar::LargeStandard,   RGB( 0, 255, 255 ), false );
    m_stdToolBar.SetBitmap( IDB_LG_DB_16,   COOBmpToolBar::LargeDisable,     RGB( 192, 192, 192 ), false );
    m_stdToolBar.InitImageList();

    // set button to dropdown list
    m_stdToolBar.SetButtonDropDown( ID_FILE_OPEN );
    m_stdToolBar.SetButtonDropDown( ID_FILE_SAVE );

    // This is a toolbar using bitmap resource file.
    if (!m_IconToolBar.Create(this) ||
        !m_IconToolBar.LoadToolBar(IDR_ICONTOOLBAR))
    {
        TRACE0("Failed to create toolbar\n");
        return -1;      // fail to create
    }

    m_IconToolBar.SetIcon( IDR_MAINFRAME, IDR_EXTOOLTYPE, IDR_EXTOOLTYPE );
    m_IconToolBar.SetIcon( IDR_EXTOOLTYPE, IDR_MAINFRAME, IDR_MAINFRAME );
    m_IconToolBar.InitImageList();

    // ... Standard stuff ...

Download demo project - 212KB

Download source - 13KB

Date Posted: 7/31/98



Comments

  • More concessions with herveleger, more coins mistaken!

    Posted by jonemuty on 04/20/2013 01:38am

    tittle of san quentin quailtoms kids outlet burberry sale picayune shavergenuine burberry uk exaltationtoms shoes outlet toms sale cheap come awaytoms shoes cheap vestalherve leger outlet hawk

    Reply
  • use CustomDraw to erase the separator in vertical position

    Posted by Legacy on 05/29/2003 12:00am

    Originally posted by: jiulun

    The separator is somehow associated with the previous button. 
    
    If you set dropdown type for one button, which is wider than the normal one.
    So the separators will come when the toolbar in vertical position.

    This can be solved by using toolbar's CustomDraw in the postpaint stage.
    Separators are redrawn with the buttonface color, so they will disappear.

    Add the prototype in OOExToolBar.hpp like this
    //}}AFX_MSG
    afx_msg void OnCustomDraw(NMHDR *pNMHDR, LRESULT *pResult);
    DECLARE_MESSAGE_MAP()

    and add the message map here
    //}}AFX_MSG_MAP
    ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)
    END_MESSAGE_MAP()

    void COOExToolBar::OnCustomDraw(NMHDR *pNMHDR, LRESULT *pResult)
    {
    // Only do this if the style is flat. In other style, there is no separator.
    if ((::GetWindowLong(m_hWnd, GWL_STYLE) & TBSTYLE_FLAT) == TBSTYLE_FLAT)
    {
    LPNMCUSTOMDRAW lpNMCD = (LPNMCUSTOMDRAW)pNMHDR;

    CDC* pDC = CDC::FromHandle(lpNMCD->hdc);

    switch (lpNMCD->dwDrawStage)
    {
    case CDDS_PREPAINT:
    // requst the postpaint message
    *pResult = CDRF_NOTIFYPOSTPAINT;
    break;

    case CDDS_POSTPAINT:
    // If the toolbar is in vertical position, erase the separator
    if(m_dwStyle & CBRS_ORIENT_VERT)
    EraseSeparators(pDC);
    break;
    }
    }
    }

    void COOExToolBar::EraseSeparators(CDC* pDC)
    {
    CToolBarCtrl& bar = GetToolBarCtrl();

    int nButtons = bar.GetButtonCount();
    for (int i = 0; i < nButtons; i++)
    {
    TBBUTTON tbb;
    GetButton(i, &tbb);
    if (tbb.fsStyle & TBSTYLE_SEP && i>0)
    {
    //???
    TBBUTTON prevButton;
    GetButton(i - 1, &prevButton);
    if (prevButton.fsStyle & TBSTYLE_SEP)
    {
    continue;
    }

    CRect rcItem;
    bar.GetItemRect( i, rcItem );

    CRect rcPrevItem;
    bar.GetItemRect( i - 1, rcPrevItem);

    rcPrevItem += CPoint(rcPrevItem.Width(), 0);
    rcPrevItem.right = rcPrevItem.left + rcItem.Width();
    rcItem = rcPrevItem;

    // The buttonface color maybe different in different style
    // comctl32.dll version >= 4.71, clrBtnFace can be got of the NMTBCUSTOMDRAW passed by customdraw
    CBrush br(::GetSysColor(COLOR_BTNFACE));
    CBrush* pOldBrush = pDC->SelectObject(&br);
    const CRect& rc=rcItem;
    pDC->PatBlt(rc.left, rc.top, rc.Width(), rc.Height(), PATCOPY);
    pDC->SelectObject(pOldBrush);
    br.DeleteObject();
    }
    }
    }

    Where function EraseSeparators is one added to the class.


    Reply
  • horizontal separators in vertical position

    Posted by Legacy on 04/08/2002 12:00am

    Originally posted by: Frog

    Hi,
    
    

    if you dock the toolbar vertical, the horizonal separators are still there. Do you know a way to remove them (in vertical mode).

    Cheers

    Reply
  • BUG: Icon text appears after changing windows scheme

    Posted by Legacy on 03/25/2002 12:00am

    Originally posted by: Simon

    When changing some window's appearance (e.g. changing the the windows scheme) the toolbar icons (after refreshing its parent) are shown with text (although SetTextMode(false) was called on creation).
    Have any solution ?
    THANKS! (really cool toolbar)

    Reply
  • Unfortunatly...

    Posted by Legacy on 02/08/2002 12:00am

    Originally posted by: Pat Laplante

    No.
    I haven't touch a window machine in ages. I've done mostly MacIntosh work in the past 2 years (porting windows application to the mac osx and os9).

    So I don't even remember how the toolbar is working! I did that under VC5 at the time with an old version of CommCtrl.dll.

    You could fix it and post your fix to the site!

    Pat

    Reply
  • Any upgrade?

    Posted by Legacy on 02/08/2002 12:00am

    Originally posted by: Ray Ku

    Your toolbar is really nice although there are some bugs. Do you have any upgrade? Can I implement your codes and toolbar bitmaps into my project?

    Thank you?


    Ray Ku

    Reply
  • Upgrade!

    Posted by Legacy on 07/09/2001 12:00am

    Originally posted by: pinktown

    The code have bugs,where have upgrade code?

    Reply
  • don't get OnSetText message when placing text to the right side

    Posted by Legacy on 04/25/2001 12:00am

    Originally posted by: Joel

    Changed this:
    ModifyStyle( 0, TBSTYLE_FLAT);
    to this:
    ModifyStyle( 0, TBSTYLE_FLAT | TBSTYLE_LIST );

    to enable the text to be to the right instead of the bottom.

    Also made a couple of minor modifications to size the button correctly when the text is there.

    However, after a couple of clicks back a forth from text to none I fail to get the OnSetText message to the MainFrame so the recalcsize never gets called.

    Wierd, have any hints?

    Reply
  • fix: flickering caused by outdated bug-fix

    Posted by Legacy on 05/13/2000 12:00am

    Originally posted by: Georg Schreiber

    in OOExToolBar.cpp there is a bug-fix in the method CCoolCmdUI::Enable which causes the toolbar to flicker on machindes with COMCTL32 V5.81 installed.

    the flickering is caused by a bug-fix for a bug thats no longer existing in V5.81 of COMCTL32.

    remove the following line to avoid this problem:

    ...
    if ( !bOn )
    {
    ...
    // nNewStyle &= ~TBBS_PRESSED; <== remove this one
    }
    ...

    Reply
  • Please send me

    Posted by Legacy on 12/30/1999 12:00am

    Originally posted by: Madhu

    hello sir,
    i could not download your demo project.i tried it many times.But all the time i failed.would you please send it to me?i have mentioned my mail id.
    thanks
    -madhu

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • You probably have several goals for your patient portal of choice. Is "community" one of them? With a bevy of vendors offering portal solutions, it can be challenging for a hospital to know where to start. Fortunately, YourCareCommunity helps ease the decision-making process. Read this white paper to learn more. "3 Ways Clinicians can Leverage a Patient Portal to Craft a Healthcare Community" is a published document owned by www.medhost.com

  • The rapid evolution of enterprise storage technologies, combined with external forces, like the explosion of big data, can cause Linux® and server administrators to play catch-up when it comes to storage. Running a bunch of monolithic storage devices and proprietary, disconnected technologies forces administrators to spend valuable time creating and managing complex solutions. To reduce complexity and enable rapid deployment of new technologies and applications, server administrators need a single open …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds