I moved the code in CreateWindowHandle. Now it works. Full code:
UNIT cAssociateExt;
INTERFACE
USES
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, Forms, StdCtrls;
TYPE
TAssociateFileExt = class(TGroupBox)
private
protected
public
btnAssociate : TButton;
btnAssociateDel: TButton;
chkAllUsers : TCheckBox;
constructor Create(aOwner: TComponent); override;
procedure AfterConstruction; override;
procedure CreateWindowHandle(const Params: TCreateParams); override;
...
published
end;
procedure Register;
IMPLEMENTATION
procedure TAssociateFileExt.AfterConstruction;
begin
inherited; //Not a good place here
end;
procedure TAssociateFileExt.CreateWindowHandle(const Params: TCreateParams);
begin
inherited;
//DO NOT CREATE CONTROLS HERE! See: Sertac Akyuz's comment
Caption:= '';
ClientHeight:= 125;
ClientWidth := 170;
end;
constructor TAssociateFileExt.Create(aOwner: TComponent);
begin
inherited Create(aOwner);
DoubleBuffered:= TRUE;
btnAssociate:= TButton.Create(Self);
btnAssociate.Parent:= Self;
btnAssociate.Visible:= TRUE;
btnAssociate.Left:= 17;
...
end;