Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7008247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:42:37+00:00 2026-05-27T21:42:37+00:00

In my custom component I created some TAction-s as subcomponents. They’re all published, but

  • 0

In my custom component I created some TAction-s as subcomponents. They’re all published, but I could not assign them at design time since they were not available through object inspector.

How do you make them “iterable” by the object inspector? I have tried to set the Owner of the actions to the Owner of the custom component (which is the hosting Form) to no success.

EDIT: It looks like Embarcadero changed Delphi IDE behaviour related with this problem. If you are using Delphi versions prior XE, you should use solution from my own answer. For XE and above, you should use solution from Craig Peterson.

EDIT: I’ve added my own answer that solves the problem, i.e. by creating a TCustomActionList instance in my custom component and setting its Owner to the hosting form (owner of the custom component). However I am not too happy with this solution, since I think the instance of TCustomActionList is kind of redundant. So I am still hoping to get better solution.

EDIT: Add code sample

uses
  .., ActnList, ..;

type
  TVrlFormCore = class(TComponent)
  private
    FCancelAction: TBasicAction;
    FDefaultAction: TBasicAction;
    FEditAction: TBasicAction;
  protected
    procedure DefaultActionExecute(ASender: TObject); virtual;
    procedure CancelActionExecute(ASender: TObject); virtual;
    procedure EditActionExecute(ASender: TObject); virtual;
  public
    constructor Create(AOwner: TComponent); override;
  published
    property DefaultAction: TBasicAction read FDefaultAction;
    property CancelAction : TBasicAction read FCancelAction;
    property EditAction   : TBasicAction read FEditAction;
  end;

implementation

constructor TVrlFormCore.Create(AOwner: TComponent);
begin
  inherited;
  FDefaultAction := TAction.Create(Self);
  with FDefaultAction as TAction do
  begin
    SetSubComponent(True);
    Caption := 'OK';
    OnExecute := DefaultActionExecute;
  end;

  FCancelAction := TAction.Create(Self);
  with FCancelAction as TAction do
  begin
    SetSubComponent(True);
    Caption := 'Cancel';
    OnExecute := Self.CancelActionExecute;
  end;

  FEditAction := TAction.Create(Self);
  with FEditAction as TAction do
  begin
    SetSubComponent(True);
    Caption := 'Edit';
    OnExecute := Self.EditActionExecute;
  end;
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:42:38+00:00Added an answer on May 27, 2026 at 9:42 pm

    As far as I can tell you’re not supposed to do it that way.

    The easy way to do what you want is to create new standalone actions that can work with any TVrlFormCore component and set the target object in the HandlesTarget callback. Take a look in StdActns.pas for examples. The actions won’t be available automatically when sommeone drops your component on the form, but they can add them to their action list manually using the New Standard Actions… command. There’s a good article on registering standard actions here.

    If you really want to auto-create the actions you need to set the action Owner property to the form and you need to set the Name property. That’s all that’s necessary, but it does introduce a bunch of issues you need to work around:

    • The form owns the actions so it will add them its declaration’s published section and will auto-create them as part of the streaming process. To work around that you can just disable streaming by overwriting the action’s WriteState method and skip the inherited behavior.
    • Since you aren’t writing the state, none of the properties will be persisted. To avoid confusing your users you should switch make the actions descend from TCustomAction instead of TAction, so it doesn’t expose anything. There may be way to make the action stream properly, but you didn’t say whether it was necessary.
    • You need to register for free notifications in case the form frees the action before you can.
    • If someone drops more than one of your component on the action names will conflict. There’s multiple ways to handle that, but the cleanest would probably be to override the component’s SetName method and use its name as a prefix for the actions’ names. If you do that you need to use RegisterNoIcon with the new class so they don’t show up on the form.
    • In the IDE’s Structure pane the actions will show up directly under the form, rather than nested like ActionList shows. I haven’t found a way around that; none of SetSubComponent, GetParentComponent/HasParent, or GetChildren have any effect, so this may be hard-coded behavior. You can delete the action from the structure pane, separate from the component, too.

    I’m sure it can be improved, but this works without any custom property editors:

    type
      TVrlAction = class(TCustomAction)
      protected
        procedure WriteState(Writer: TWriter); override;
      end;
    
      TVrlFormCore = class(TComponent)
      private
        FDefaultAction: TVrlAction;
      protected
        procedure DefaultActionExecute(ASender: TObject); virtual;
        procedure Notification(AComponent: TComponent;
          Operation: TOperation); override;
        procedure SetName(const NewName: TComponentName); override;
      public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
      public
        property DefaultAction: TVrlAction read FDefaultAction;
      end;
    
    procedure Register;
    
    implementation
    
    // TVrlAction
    
    procedure TVrlAction.WriteState(Writer: TWriter);
    begin
      // No-op
    end;
    
    // TVrlFormCore
    
    constructor TVrlFormCore.Create(AOwner: TComponent);
    begin
      inherited;
      FDefaultAction := TVrlAction.Create(AOwner);
      with FDefaultAction do
      begin
        FreeNotification(Self);
        Name := 'DefaultAction';
        Caption := 'OK';
        OnExecute := DefaultActionExecute;
      end;
    end;
    
    destructor TVrlFormCore.Destroy;
    begin
      FDefaultAction.Free;
      inherited;
    end;
    
    procedure TVrlFormCore.DefaultActionExecute(ASender: TObject);
    begin
    
    end;
    
    procedure TVrlFormCore.Notification(AComponent: TComponent;
      Operation: TOperation);
    begin
      inherited;
      if Operation = opRemove then
        if AComponent = FDefaultAction then
          FDefaultAction := nil;
    end;
    
    procedure TVrlFormCore.SetName(const NewName: TComponentName);
    begin
      inherited;
      if FDefaultAction <> nil then
        FDefaultAction.Name := NewName + '_DefaultAction';
    end;
    
    procedure Register;
    begin
      RegisterComponents('Samples', [TVrlFormCore]);
      RegisterNoIcon([TVrlAction]);
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created for my application, some custom GUI component and used them. Now
I've created a custom component that display some data to the page according to
I have created a custom facelets component and I need to set some value
I've created some TracReports but trying to do them with SQL, I don't get
I'm creating some custom components and backing code. I've created a Flex library project
I'm trying to create with Delphi a component inherited from TLabel, with some custom
I created a custom button component that accepts an array as a property. I
I have a component I created that works like a Viewstack but the next
I have created a custom component. I add a dynamic input text box to
How do you create your own custom component for vb.net 2008? I want it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.