如何将按钮添加到自定义工具栏 [英] How to add a button to a custom toolbar

查看:118
本文介绍了如何将按钮添加到自定义工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有EnableVSIPLogging,当我点击我的自定义工具栏的现有按钮时,我得到一个GUID / CmdId对,但是CmdID指的是我点击的命令而不是工具栏


根据我的理解,我无法将我的命令添加到工具栏,除非我有工具栏的CmdID所以我该怎么做?

解决方案

我假设您知道按钮(命令)放在组上,而不是放在工具栏/命令栏上。组是放在工具栏/命令栏上的组:


CommandBar - >组(s) - >按钮


澄清:


A)如果工具栏是"自定义",您已创建它,因此您知道它的Guid / Id,它不包含任何组,因此您必须:


1)创建一个组并将其放在工具栏上


2)创建命令并将其放在组上


在此处查看我的示例CommandToolbar:


https://github.com/visualstudioextensibility/VSX-Samples


B)如果工具栏是"内置的",则创建Visual Studio它,包含带按钮的组。所以你有两个选择:



B1)要创建一个组,将它放在工具栏上(你必须猜测Guid / Id工具栏),创建一个按钮并将其放在组上


B2)创建一个按钮并将其放在工具栏的现有组上(你必须猜测它的Guid / Id组,而不是工具栏的Guid / Id。)


参见:


https://blogs.msdn.microsoft.com/ dr._ex / 2007/04/17 / using-enablevsiplogging-to-identify-menus-and-commands-with-vs-2005-sp1 /



I have EnableVSIPLogging and when I click to an existing button of my custom toolbar i get a GUID/CmdId pair however the CmdID refers to the command I clicked and not to the toolbar

As I understand it I cannot add my commands to the toolbar unless I have the CmdID of the toolbar so how do I get that?

解决方案

I assume that you know that buttons (commands) are placed on groups, not on toolbars/commandbars. Groups are the ones that are placed on toolbars/commandbars:

CommandBar -> Group(s) -> Buttons(s)

That clarified:

A) If the toolbar is "custom", you have created it, so you know its Guid/Id, and it contains no groups, so you have to:

1) Create a group and place it on the toolbar

2) Create a command and place it on the group

See my sample CommandToolbar here:

https://github.com/visualstudioextensibility/VSX-Samples

B) If the toolbar is "built-in", Visual Studio created it, and contains groups with buttons. So you have two options:

B1) To create a group, place it on the toolbar (and you must guess the Guid/Id of the toolbar), create a button and place it on the group

B2) To create a button and place it on an existing group of the toolbar (and you must guess the Guid/Id of the group, not the Guid/Id of the toolbar).

See:

https://blogs.msdn.microsoft.com/dr._ex/2007/04/17/using-enablevsiplogging-to-identify-menus-and-commands-with-vs-2005-sp1/


这篇关于如何将按钮添加到自定义工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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