I created a component that has a TVaComm as a private member according to the following simplified model:
unit sstest;
interface
uses
Winapi.Windows, Winapi.Messages,
System.SysUtils, System.Variants, System.Classes, System.IniFiles,
Vcl.ExtCtrls, VaClasses, VaComm;type
TssTest = class(TComponent)
private
fComm: TVaComm;
fPort: integer;
procedure SetPort(Value: integer);
function GetPort: integer;
public
constructor Create(AOwner: TComponent);
destructor Destroy;
published
property Port: integer read GetPort write fPort;
end;procedure Register;
implementation
{ TssTest }
constructor TssTest.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fComm := TVaComm.Create(self);
end;destructor TssTest.Destroy;
begin
fComm.Free;
end;function TssTest.GetPort: integer;
begin
Result := fComm.PortNum;
end;procedure TssTest.SetPort(Value: integer);
begin
fComm.PortNum := Value;
end;procedure Register;
begin
RegisterComponents('MyComponents', [TssTest]);
end;end.
When I create the component in an application at runtime it is working well.
But when I try to place the component from the component palette to a form it crashes with a lot of error messages from Delphi.
May be this is not a problem of TVaComm itself, but more of my insufficient knowledge about component development. But I tried to find a solution in the web without success, so I hope someone can help me here.
Regards