Export (0) Print
Expand All

How to: Read from and Write to the Feedback Region of the Status Bar

The Feedback region of the Visual Studio status bar displays text. You can set and retrieve text, display static text, and highlight the displayed text.

To use the Feedback region of the Visual Studio Status bar

  1. Obtain an instance of the IVsStatusbar interface, which is made available through the SVsStatusbar service.

  2. Determine whether the status bar is frozen by calling the IsFrozen method of the IVsStatusbar instance.

  3. Set the text of the Feedback region by calling the SetText method and passing in a text string.

  4. Read the text of the Feedback region by calling the GetText method.

This example demonstrates how to write text to and read text from the Feedback region.

void FeedbackRegionExample()
{
    IVsStatusbar statusBar =
        (IVsStatusbar)GetService(typeof(SVsStatusbar));
    int frozen;

    statusBar.IsFrozen(out frozen);

    if (frozen == 0)
    {
        // Set the status bar text and make its display static.
        statusBar.SetText("Here's some static text.");
        statusBar.FreezeOutput(1);

        // Retrieve the status bar text. 
        string text;
        statusBar.GetText(out text);
        System.Windows.Forms.MessageBox.Show(text);

        // Clear the status bar text.
        statusBar.FreezeOutput(0);
        statusBar.Clear();
    }
}

In the above example, the code does the following things:

  • Obtains an instance of the IVsStatusbar interface from the SVsStatusbar service.

  • Checks to see if the status bar is frozen by calling the IsFrozen method.

  • Inhibits further updates to the status bar by calling the FreezeOutput method.

  • Reads the text from the status bar by calling the GetText method and displays it in a message box.

  • Allows updates to the status bar by calling FreezeOutput and passing 0 in the parameter.

  • Clears the contents of the status bar by calling the Clear method.

Show:
© 2014 Microsoft