Bagikan melalui


Macros.Parent Property

Gets the immediate parent object of a Macros object.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
ReadOnly Property Parent As DTE
'Usage
Dim instance As Macros 
Dim value As DTE 

value = instance.Parent
DTE Parent { get; }
property DTE^ Parent {
    DTE^ get ();
}
function get Parent () : DTE

Property Value

Type: EnvDTE.DTE
A DTE object.

Remarks

The Parent property returns the immediate parent to the object or collection.

Examples

public void CodeExample(DTE2 dte, AddIn addin)
{
    // INSTRUCTIONS: Run this code, open a solution, start
    // recording a macro, then connect the addin containing this code.
    try
    {
        Macros mac = dte.Macros;
        if (mac.IsRecording)
        {
            mac.Pause();
            if (!mac.IsRecording)
                mac.Resume();
            mac.EmitMacroCode("rem Code added by the EmitMacroCode method");
            // Demonstrate these two properties return the same reference.
            bool test = mac.DTE.Equals(mac.Parent);
            if (test) MessageBox.Show("The DTE and Parent property refer to the same object.");
            else MessageBox.Show("The DTE and Parent property do not refer to the same object.");
        }
        else MessageBox.Show("Start a macro recording session and reconnect addin");
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework Security

See Also

Reference

Macros Interface

Macros Members

EnvDTE Namespace

Other Resources

How to: Compile and Run the Automation Object Model Code Examples