Changing a buttons icon in with the visual studio SDK

こ雲淡風輕ζ 提交于 2019-12-25 02:40:35

问题


I am using the Visual Studio SDK to add in some additional functionality to visual studio.

I have a button that when pressed will perform a potentially long running task (maybe 10-15 seconds) and I would like to change the button Icon to include some indication that the task is being performed, and then again change the icon to show that the task has been completed.

Reading through the MSDN articles has shown me how to customise my icon, but I am having trouble figuring out how to change it at run time. The MSDN article configures its icons in an xml config file.

Essentially my question is how do I control the button icon in code? I have provided the link to the MSDN article that I have been using below

http://msdn.microsoft.com/en-us/library/bb165158.aspx

Thanks in advance

James


回答1:


It is not a good idea (it's non standard, you can use a progress dialog or the status bar of VS instead), but if you really want you can try the following approach:

1) Get the CommandBar that has the button

2) Get the CommandBarControl in the CommandBar.Controls collection

3) Cast the CommandBarControl to CommandBarButton

4) Use the CommandBarButton.Picture and CommandBarButton.Mask properties. See section #2 of my article:

HOWTO: Creating custom pictures for Visual Studio .NET add-ins commands, buttons and toolwindows.



来源:https://stackoverflow.com/questions/21891635/changing-a-buttons-icon-in-with-the-visual-studio-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!