需要一个示例来自定义Visual Studio状态栏 [英] Need a sample for customizing Visual Studio status bar

查看:74
本文介绍了需要一个示例来自定义Visual Studio状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请为我提供一个非常简单的VS Package C#项目,用于自定义Visual Studio的状态栏。我只是想在状态栏中显示一条消息,没有别的。因为我是初学者,所以互联网和msdn的样本都不起作用,也不复杂。在此先感谢。



当我尝试下面的代码时,它在GetService中显示错误为在相关上下文中不存在。



Please provide me a very simple VS Package C# project for customizing Visual Studio's status bar. I just want to display a message in the status bar, nothing else. The samples which are in internet and also msdn are not working and little complex since I'm a beginner. Thanks in advance.

While I'm trying the below code, it shows error in GetService as "doesn't exists in the corrent context".

IVsStatusbar statusBar = (IVsStatusbar)GetService(typeof(SVsStatusbar));
int frozen;
statusBar.IsFrozen(out frozen);
if (frozen == 0)
{
    statusBar.SetText("Here's some static text.");
}





通过使用语句IVsStatusbar statusbar =(IVsStatusbar)GetService(typeof(SVsStatusbar)),我可以实现包类中的要求。但是,如果我在另一个不是包类的类中使用相同的,它就不起作用了。无法使用GetService方法。它显示为GetService在当前上下文中不存在。如何从另一个类获取服务,或者我可以从Package类获取服务并将其传递给另一个类?我正在使用VS2010进行编码。



By using the statement IVsStatusbar statusbar=(IVsStatusbar)GetService(typeof(SVsStatusbar)), I can achieve the requirement in package class. But if I'm using the same in another class which is not a package class, its not working. Unable to use GetService method. Its showing as "GetService doesn't exists in the current context". How can I get the service from an another class or can I get the service from the Package class and pass it to an another class? I'm using VS2010 to code.

推荐答案

此网站用于询问您遇到问题时编写的代码的具体问题。如果你已经尝试过互联网上的代码并且它不起作用,那么发布你所做的并提出问题。但我们不会只交出你需要的一切。
This site is for asking specific questions on code that you have written when you get stuck. If you have tried code from the internet and it does not work then post what you have done and ask a question. But we won't just hand you everything you need.


这篇关于需要一个示例来自定义Visual Studio状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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