The THYObjectReference base class implements the IHYVCLObjectReference interface and provides basic functionality needed to access an object wrapped by other objects, such as user interface items.

Use Case

You do not need to use this class directly, instead, you can use the IHYVCLObjectReference interface to access an underlying object. For example:

procedure TTextEditorPlugin.HYPluginControlsRepository1AfterMergeMenuItems(
  Sender: THYPluginControlsRepository; const aHost: IHYVCLHost;
  const anUpdateID: TGUID);
  FileMenu : IHYVCLMenuItem;
  if (Host.MenuController=NIL) then Exit;

  FileMenu := Host.MenuController.Items.MenuItemByCaption('File');
  ((FileMenu as IHYVCLObjectReference).RefObject as TMenuItem).Caption := 'New Caption';

Alternatively, you could set the properties using Properties, with code like this:

  (FileMenu as IHYVCLObjectReference).Properties['Caption'] := 'New Caption';


Instance Methods

constructor Create  reintroduce virtual

Creates a new instance of the class.

constructor Create(anObject: TObject; OwnsObject: Boolean)


  • anObject: Object that is wrapped by this class, if anObject is nil, an EHYException is raised.
  • OwnsObject: If set to true, the referenced object will be freed when this class is destroyed.

DestroyObject  protected

Destroys the referenced object.

procedure DestroyObject

GetProperty  protected

Retrieves the value of the published property of the referenced object.

function GetProperty(const aName: string): variant


  • aName: Name of the property.

GetRefObject  protected

Gets referenced object.

function GetRefObject: TObject

SetProperty  protected

Sets the value of the published property of the referenced object.

procedure SetProperty(const aName: string; const aPropertyValue: variant)


  • aName: Name of the property.
  • aPropertyValue: Value of the property.