Export (0) Print
Expand All

WindowConfiguration Creation Example 

This example demonstrates how to create, reference, and delete a window configuration.

To use this example, copy the following code into a new add-in project, and then run the first procedure, WinConfigExample1, in the add-in's OnConnection method. For more information on how to run the following code samples in an add-in, see How to: Compile and Run the Automation Object Model Code Examples.

Example

void WinConfigExample1(_DTE dte)
{
    //Set references to all necessary objects.
    WindowConfigurations colWinConfig; 
    WindowConfiguration objWinConfig;

    colWinConfig = dte.WindowConfigurations;
    MessageBox.Show("Number of configurations: " + 
    colWinConfig.Count);

    // List all saved named window configurations.
    FillMsg(colWinConfig);
    //Create a new window configuration.
    objWinConfig = colWinConfig.Add("NewLayout");
    FillMsg(colWinConfig);
    // Delete the new window configuration.
    objWinConfig.Delete();
    MessageBox.Show("Number of configurations: " + 
    colWinConfig.Count);
    FillMsg(colWinConfig);
}

void FillMsg(WindowConfigurations colWinConfig )
{
    // Lists all currently available named window configurations.
    int lCtr;
    string strMsg = null;

    for (lCtr = 1; lCtr < colWinConfig.Count + 1; lCtr ++)
    {
        strMsg = strMsg + "Configuration name " + lCtr + ": " + 
        colWinConfig.Item(lCtr).Name + "\n"; 
    }
    strMsg = "Current Configurations: \n" + strMsg;
    MessageBox.Show(strMsg);
}

See Also

Community Additions

ADD
Show:
© 2014 Microsoft