TUnitComands = class(TComponent)
protected
{ Protected declarations }
Comands: TList; //Команды
....................
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
....................
function Add (code: Integer; name: string; metod: T_MetodComand; countParam: TCountParam=0): Integer; // добавляет эллемент
....................
end;
constructor TUnitComands.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Comands:=TList.Create;
end;
destructor TUnitComands.Destroy;
begin
Comands.Free;
inherited Destroy;
end;
function TUnitComands.Add (code: integer; name: string; metod: T_MetodComand; countParam: TCountParam=0): Integer;
var comand: P_ComandOptions;
begin
new(comand);
comand.code:=code;
comand.name:=name;
comand.metod:=metod;
comand.CountParam:=countParam;
result:= Comands.add(comand); // <- Вылетает ошибка EAccessViolation
end;
Слздание компонентов.
Код:
T_MetodComand - укзатель на функцию
P_ComandOptions - указатель на запись
TCountParam=-1..65533;
Ошибка вылетает только если TUnitComands на форме как компонент. если я его создаю вручную UnitComands:=TUnitComands.Create(Application);, то всё работает нормально. Конструктор выполяется и Comands создаётся (был nil, стал адрес)!!!!
Подскажите пожалуста, КАК СИЁ ПОНИМАТЬ?????:x
:)
Хоть чего нибуть то скажите, а то ведь компоненты то не получаются именно из-за этого....
Если надо исходники выложу..))
:D Всё оказалось черезвычайно просто и даже глуппо.
Но всё равно спасибо.