Contents

addproperty

Add custom property to COM object

Syntax

addproperty(h,'name')

Description

addproperty(h,'name') adds custom property specified in string, name, to object or interface, h.

COM functions are available on Microsoft® Windows® systems only.

Examples

This example adds a custom property to the MATLAB® sample control.

  1. Create an instance of the control:

    f = figure('position',[100 200 200 200]);
    h = actxcontrol('mwsamp.mwsampctrl.2',[0 0 200 200],f);
    get(h)
    
         Label: 'Label'
        Radius: 20
    

    MATLAB also displays interfaces.

  2. Add a custom property named Position and assign a value:

    addproperty(h,'Position');
    h.Position = [200 120];
    get(h)
    
           Label: 'Label'
          Radius: 20
        Position: [200 120]
  3. Delete the custom property Position:

    deleteproperty(h,'Position');
    get(h)
    
         Label: 'Label'
        Radius: 20

    MATLAB displays the original list of properties:

Was this topic helpful?