Frequently Asked Component Specific Questions

Options

Display all FAQ items

Search FAQ items:


Displaying items 1 to 1 of 1, page 1 of 1

<< previous next >>

TAdvAlertWindow
Create descending class with custom TMsgCollectionItem classes

Starting from version 1.8, it is possible to create a descendent class of TAdvAlertWindow where it is possible to use a custom extended class of TMsgCollectionItem as AlertMessages collection. This code makes it clear how this can be done:
type
  TMsgCollectionItemEx = class(TMsgCollectionItem)
  private
    FExtra: string;
  published
    property Extra: string read FExtra write FExtra;
  end;

  TMsgCollectionEx = class(TMsgCollection)
  protected
    function GetItemClass: TCollectionItemClass; override;
  end;

  TAdvAlertWindowEx = class(TAdvAlertWindow)
  protected
    function CreateMsgCollection: TMsgCollection; override;
  end;

implementation

{ TMsgCollectionEx }

function TMsgCollectionEx.GetItemClass: TCollectionItemClass;
begin
  Result := TMsgCollectionItemEx;
end;

{ TAdvAlertWindowEx }

function TAdvAlertWindowEx.CreateMsgCollection: TMsgCollection;
begin
  Result := TMsgCollectionEx.Create(Self);
end;