Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.

Public Report
Report From: Delphi-BCB/VCL    [ Add a report in this area ]  
Report #:  135152   Status: Open
TComponent.PaletteCreated is never called
Project:  Delphi Build #:  23.0.21418.4207
Version:    21.0 Submitted By:   Yuriy Afanasenkov
Report Type:  Minor failure / Design problem Date Reported:  12/11/2015 12:14:59 AM
Severity:    Infrequently encountered problem Last Updated: 12/14/2015 6:22:28 AM
Platform:    All platforms Internal Tracking #:   72852
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
Protected dynamic procedure TComponent.PaletteCreated was introduced at least in Delphi 7 (maybe earlier) and supposed to be called automatically at design time when component is created from component palette.

But in all versions of Delphi I tried, including delphi 10 Seattle, it is never called.
Steps to Reproduce:
Create new component:

unit Button1;

interface

uses
  System.SysUtils, System.Classes, Vcl.Controls, Vcl.StdCtrls;

type
  TTestButton = class(TButton)
  private
    { Private declarations }
  protected
    procedure PaletteCreated; override;
    { Protected declarations }
  public
    constructor Create(aOwner: TComponent); override;
    { Public declarations }
  published
    { Published declarations }
  end;

procedure Register;

implementation

uses forms;

procedure Register;
begin
  RegisterComponents('Samples', [TTestButton]);
end;

constructor TTestButton.Create(aOwner: TComponent);
begin
  inherited;
  Application.MessageBox('Test button created','whatever');
end;

procedure TTestButton.PaletteCreated;
begin
  inherited;
  Application.MessageBox('Test button palette created','whatever');
end;

end.

Install it to component palette and then put to form. 'Test button created' message is shown, but 'Test button palette created' is not.
Workarounds
The simplest solution is to mention in documentation (http://docwiki.embarcadero.com/Libraries/Seattle/en/System.Classes.TComponent.PaletteCreated)
that this procedure is not actually called.

Better way is to implement this call from IDE at last.
Attachment
None
Comments

Yuriy Afanasenkov at 12/17/2015 1:19:21 PM -
Also, see here:

http://stackoverflow.com/questions/33926320/display-a-warning-when-dropping-a-component-on-a-form-at-design-time/33927688#33927688

Problem is well reproducible, there are also workarounds, ways to 'emulate' IDE call to PaletteCreated.

Server Response from: ETNACODE01