very large toolbar buttons - Programmer

This is a discussion on very large toolbar buttons - Programmer ; Somehow all of my toolbar items are ending up at a size of 135x40. I have tried setting the size down to what it should be, 20x20 for the bitmap size and 27x26 for the button size but for some ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: very large toolbar buttons

  1. very large toolbar buttons

    Somehow all of my toolbar items are ending up at a size of 135x40. I
    have tried setting the size down to what it should be, 20x20 for the
    bitmap size and 27x26 for the button size but for some reason after the
    application finishes loading up and goes into the idle processing the
    sizes pop back to the large size. I happen to be using Ultimate
    Toolbox, but it sets/gets all of it's size data from the standard MFC
    CToolBarCtrl.

    If I don't bother calling SetSizes then the toolbar buttons start out
    and stay at 135x40. The toolbar is drawn with the very large buttons
    and all of them are visible.
    (screen shot)
    http://www.solarflarestudios.com/tem...eally_huge.jpg
    If I do call SetSizes then the buttons shrink down to the size that I
    specify and the toolbar is drawn at a normal size for a short amount of
    time.
    (screen shot) http://www.solarflarestudios.com/temp/buttons_huge.jpg
    After a while (it really vaires) they pop to the large size trapped in
    the small toolbar.
    (screen shot) http://www.solarflarestudios.com/tem...ons_normal.jpg

    I have put a break point in CToolBar::SetSizes and it never gets called
    with dimensions other than what I expect, in other words I never see
    135x40 float on through there.

    The size of the button is being returned by a call to
    CToolBarCtrl::GetItemRect and this is returning the large rectangle.
    Now I can't figure out where it ever gets the huge size from.

    One thing to note is that I am not using LoadToolbar but instead am
    constructing the toolbar buttons myself, since the buttons are
    added/removed dynamically during runtime. I have looked through
    LoadToolbar and can't find anything that it is doing that I am not
    doing. Another important thing is that sometimes buttons stay at the
    correct size for a while and then get bigger later. Doing something
    like locking/unlocking the taskbar is one way to make the buttons flip
    to their huge size.

    I have been trying to figure out what is going on here for a couple of
    days with no luck. Does anybody have any ideas or hints as to where I
    should go looking?


  2. Re: very large toolbar buttons

    It looks like I am doing something fishy and it is somewhere in the
    code snippets below. I tried just loading a toolbar from the resource
    editor that has one button and it does not have the expanding problems.


    In the following snippets pToolBar is a pointer to a CToolBar object,
    technically a COXSizeToolBar because of Ultimate Toolbox but that
    should not make any difference. m_toolbarIL is a CImageList


    In order to build the toolbar I first delete all of the buttons from it

    by doing:
    while ( pToolBar->GetToolBarCtrl().DeleteButton(0) == TRUE ){}


    Then I create a new image list:
    m_toolbarIL.DeleteImageList();
    m_toolbarIL.Create(20, 20, ILC_COLOR24 | ILC_MASK, 1, 1);


    I add each button manually using the sequence below:


    CBitmap bmpImage;
    TBBUTTON tbButton;
    tbButton.iBitmap = -1;
    tbButton.iString = -1;
    tbButton.fsState = TBSTATE_ENABLED;
    tbButton.fsStyle = TBSTYLE_BUTTON;
    tbButton.idCommand = 0;


    tbButton.idCommand = nCommandID;
    bmpImage.LoadBitmap( nBitmapID );
    tbButton.iBitmap = m_toolbarIL.Add(&bmpImage, RGB(255, 0, 255));
    tbButton.iString = pToolBar->GetToolBarCtrl().AddStrings( strItemName
    );
    pToolBar->GetToolBarCtrl().SetImageList(&m_toolbarIL);
    pToolBar->GetToolBarCtrl().InsertButton(nIndex, &tbButton);


    Am I doing something wrong here?


    stephen2002 wrote:
    > Somehow all of my toolbar items are ending up at a size of 135x40. I
    > have tried setting the size down to what it should be, 20x20 for the
    > bitmap size and 27x26 for the button size but for some reason after the
    > application finishes loading up and goes into the idle processing the
    > sizes pop back to the large size. I happen to be using Ultimate
    > Toolbox, but it sets/gets all of it's size data from the standard MFC
    > CToolBarCtrl.
    >
    > If I don't bother calling SetSizes then the toolbar buttons start out
    > and stay at 135x40. The toolbar is drawn with the very large buttons
    > and all of them are visible.
    > (screen shot)
    > http://www.solarflarestudios.com/tem...eally_huge.jpg
    > If I do call SetSizes then the buttons shrink down to the size that I
    > specify and the toolbar is drawn at a normal size for a short amount of
    > time.
    > (screen shot) http://www.solarflarestudios.com/temp/buttons_huge.jpg
    > After a while (it really vaires) they pop to the large size trapped in
    > the small toolbar.
    > (screen shot) http://www.solarflarestudios.com/tem...ons_normal.jpg
    >
    > I have put a break point in CToolBar::SetSizes and it never gets called
    > with dimensions other than what I expect, in other words I never see
    > 135x40 float on through there.
    >
    > The size of the button is being returned by a call to
    > CToolBarCtrl::GetItemRect and this is returning the large rectangle.
    > Now I can't figure out where it ever gets the huge size from.
    >
    > One thing to note is that I am not using LoadToolbar but instead am
    > constructing the toolbar buttons myself, since the buttons are
    > added/removed dynamically during runtime. I have looked through
    > LoadToolbar and can't find anything that it is doing that I am not
    > doing. Another important thing is that sometimes buttons stay at the
    > correct size for a while and then get bigger later. Doing something
    > like locking/unlocking the taskbar is one way to make the buttons flip
    > to their huge size.
    >
    > I have been trying to figure out what is going on here for a couple of
    > days with no luck. Does anybody have any ideas or hints as to where I
    > should go looking?



  3. Re: very large toolbar buttons

    And the answer to "am I doing something wrong here" would be "yes". I
    knew that
    "tbButton.iString" was supposed to be some sort of string but I could
    never find in the documentation what exactly that string was used for.
    Apparently it is used to draw text on the button, so I guess the
    buttons were being sized large enough to display the text onto the
    button.

    Leaving tbButton.iString = -1 fixed the problem.


    stephen2002 wrote:
    > It looks like I am doing something fishy and it is somewhere in the
    > code snippets below. I tried just loading a toolbar from the resource
    > editor that has one button and it does not have the expanding problems.
    >
    >
    > In the following snippets pToolBar is a pointer to a CToolBar object,
    > technically a COXSizeToolBar because of Ultimate Toolbox but that
    > should not make any difference. m_toolbarIL is a CImageList
    >
    >
    > In order to build the toolbar I first delete all of the buttons from it
    >
    > by doing:
    > while ( pToolBar->GetToolBarCtrl().DeleteButton(0) == TRUE ){}
    >
    >
    > Then I create a new image list:
    > m_toolbarIL.DeleteImageList();
    > m_toolbarIL.Create(20, 20, ILC_COLOR24 | ILC_MASK, 1, 1);
    >
    >
    > I add each button manually using the sequence below:
    >
    >
    > CBitmap bmpImage;
    > TBBUTTON tbButton;
    > tbButton.iBitmap = -1;
    > tbButton.iString = -1;
    > tbButton.fsState = TBSTATE_ENABLED;
    > tbButton.fsStyle = TBSTYLE_BUTTON;
    > tbButton.idCommand = 0;
    >
    >
    > tbButton.idCommand = nCommandID;
    > bmpImage.LoadBitmap( nBitmapID );
    > tbButton.iBitmap = m_toolbarIL.Add(&bmpImage, RGB(255, 0, 255));
    > tbButton.iString = pToolBar->GetToolBarCtrl().AddStrings( strItemName
    > );
    > pToolBar->GetToolBarCtrl().SetImageList(&m_toolbarIL);
    > pToolBar->GetToolBarCtrl().InsertButton(nIndex, &tbButton);
    >
    >
    > Am I doing something wrong here?
    >
    >
    > stephen2002 wrote:
    > > Somehow all of my toolbar items are ending up at a size of 135x40. I
    > > have tried setting the size down to what it should be, 20x20 for the
    > > bitmap size and 27x26 for the button size but for some reason after the
    > > application finishes loading up and goes into the idle processing the
    > > sizes pop back to the large size. I happen to be using Ultimate
    > > Toolbox, but it sets/gets all of it's size data from the standard MFC
    > > CToolBarCtrl.
    > >
    > > If I don't bother calling SetSizes then the toolbar buttons start out
    > > and stay at 135x40. The toolbar is drawn with the very large buttons
    > > and all of them are visible.
    > > (screen shot)
    > > http://www.solarflarestudios.com/tem...eally_huge.jpg
    > > If I do call SetSizes then the buttons shrink down to the size that I
    > > specify and the toolbar is drawn at a normal size for a short amount of
    > > time.
    > > (screen shot) http://www.solarflarestudios.com/temp/buttons_huge.jpg
    > > After a while (it really vaires) they pop to the large size trapped in
    > > the small toolbar.
    > > (screen shot) http://www.solarflarestudios.com/tem...ons_normal.jpg
    > >
    > > I have put a break point in CToolBar::SetSizes and it never gets called
    > > with dimensions other than what I expect, in other words I never see
    > > 135x40 float on through there.
    > >
    > > The size of the button is being returned by a call to
    > > CToolBarCtrl::GetItemRect and this is returning the large rectangle.
    > > Now I can't figure out where it ever gets the huge size from.
    > >
    > > One thing to note is that I am not using LoadToolbar but instead am
    > > constructing the toolbar buttons myself, since the buttons are
    > > added/removed dynamically during runtime. I have looked through
    > > LoadToolbar and can't find anything that it is doing that I am not
    > > doing. Another important thing is that sometimes buttons stay at the
    > > correct size for a while and then get bigger later. Doing something
    > > like locking/unlocking the taskbar is one way to make the buttons flip
    > > to their huge size.
    > >
    > > I have been trying to figure out what is going on here for a couple of
    > > days with no luck. Does anybody have any ideas or hints as to where I
    > > should go looking?



+ Reply to Thread