Click here to Skip to main content
15,063,085 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating MDI application. By default it uses by default toolbar resource IDR_MAINFRAME_256 and class
.How to hide and show particular toolbar button. I require this functionality as there are different users with
different user rights are going to use this Software. Please anyone can tell me
How should I show or hide particular toolbar button.
I tried RemoveButton and InsertButton(gives error as cannot use private fuction)

I also tried

    m_wndToolBar.SendMessage(TB_HIDEBUTTON, ID_TESTVIEW, (LPARAM)&inf); 

but it does not work at all.
Can anyone tell me please how to go about it.

I ran into the same problem. It seems that CMFCToolBar does not react on TB_HIDEBUTTON anymore. I think you have to use the visible style on the buttons, e.g.:

void HideButton(CMFCToolBar* pToolBar, int nID, bool bHide)
    //NOTE: TB_HIDEBUTTON does not work anymore

    const int nIndex = pToolBar->CommandToIndex(nID);

    if (nIndex != -1)
        CMFCToolBarButton* pButton = pToolBar->GetButton(nIndex);
        if (pButton)

adityarao31 19-Sep-12 7:42am
My Friend I want to hide button in onc case,show it in another case.RemoveButton works fine,but InsertButton is private function so we cannot use it,So If I use this method how can I show Button again

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900