tags:

views:

47

answers:

1

I'm currently disable certain buttons by handling ON_UPDATE_COMMAND_UI and calling ->Enable( TRUE / FALSE ).

What would be the best way to completely hide the button instead?

I've tried using HideButton and that makes the button image invisible, but it still takes up space so there is a blank area between visible buttons.

Thanks.

A: 

Try to call toolbar.SendMessage(TB_AUTOSIZE); after the HideButton();

I would recommend to show/hide those buttons elsewhere than OnUpdateCommandUI because these occur too often and may cause flicker. Although not MFC I have a similar code that works:

void HideToolbarButton(HWND toolbar, UINT command_id)
{
    TBBUTTONINFO tbinfo;
    tbinfo.cbSize = sizeof(tbinfo);
    tbinfo.dwMask = TBIF_STATE;
    tbinfo.state  = TBSTATE_HIDDEN;
    SendMessage(toolbar, TB_SETBUTTONINFO, command_id, (LPARAM)&tbinfo );
}
Tassos