如何在VC ++ 2010专业版中隐藏工具栏按钮 [英] How to hide toolbar button in VC++ 2010 professional

查看:485
本文介绍了如何在VC ++ 2010专业版中隐藏工具栏按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建MDI应用程序。默认情况下,它默认使用工具栏资源IDR_MAINFRAME_256和类

I am creating MDI application. By default it uses by default toolbar resource IDR_MAINFRAME_256 and class

CMFCToolBar

。如何隐藏和显示特定的工具栏按钮。我需要此功能,因为有不同的用户

不同的用户权限将使用此软件。请任何人都可以告诉我

我应该如何显示或隐藏特定的工具栏按钮。

我尝试了RemoveButton和InsertButton(由于不能使用私有功能而给出错误)



我也试过



.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

TBBUTTONINFO inf;
    inf.cbSize=sizeof(inf);
    inf.dwMask=TBIF_STYLE;
    inf.fsStyle=BTNS_DROPDOWN | BTNS_AUTOSIZE ;
    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.

推荐答案

参见 MSDN文档 [ ^ ]。


http://msdn.microsoft.com/en-us/library/bb983035.aspx [ ^ ]


我遇到了同样的问题。似乎CMFCToolBar不再对TB_HIDEBUTTON作出反应。我认为你必须使用按钮上的可见样式,例如:



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)
        {
            pButton->SetVisible(!bHide);

            pToolBar->AdjustSizeImmediate();
        }
    }
}


这篇关于如何在VC ++ 2010专业版中隐藏工具栏按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆