OK,
I have found that I have a class, which I instantiate.
However this class contains ACTIVE := FALSE. in its create sequence.
The below code in "UniSQLMonitor.pas" has been my downfall.
This code automatically instantiates it's own object. A move I had
not countered on. Which renders my ACTIVE := FALSE statement impotent.
I have also attached the class I created based on TUniSQLMonitor.
I can see I needed to descend it from TCustomDASQLMonitor instead and
set my options to [moDialog, moSQLMonitor, moCustom];
var
UniMonitor: TUniSQLMonitor;
{ TUniSQLMonitor }
constructor TUniSQLMonitor.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
if UniMonitor = nil then
UniMonitor := Self;
end;
The class I created in my code is this:
TV2Monitor = class( TUniSQLMonitor )
private
slSQL : TStringList;
FMaxTrace : Integer;
function GetMonitorEnabled: Boolean;
procedure SetMonitorEnabled(const Value: Boolean);
function GetMaxTrace: Integer;
procedure SetMaxTrace(const Value: Integer);
procedure AddToList(Sender: TObject; Text: string; Flag: TDATraceFlag);
public
property MonitorEnabled:Boolean read GetMonitorEnabled write SetMonitorEnabled;
property MaxTrace : Integer read GetMaxTrace write SetMaxTrace default 10000;
constructor Create(AOwner: TComponent); override;
destructor Destroy;override;
procedure SaveToFile( FileName : String );
end;
{ TV2Monitor }
procedure TV2Monitor.AddToList(Sender: TObject; Text: string; Flag: TDATraceFlag);
var
slText : TStringList;
begin
slSQL.Add( FormatDateTime('YYYYMMDDHHNNSSZZZ', Now ));
slText := TStringList.Create;
slText.Text := Text;
slSQL.AddStrings(slText);
FreeAndNil(slText);
while( slSQL.Count > FMaxTrace )do
slSQL.Delete(0);
end;
constructor TV2Monitor.Create(AOwner: TComponent);
begin
inherited;
slSQL := TStringList.Create;
OnSQL := AddToList;
Active := FALSE;
end;
destructor TV2Monitor.Destroy;
begin
FreeAndNIl( slSQL );
inherited;
end;
function TV2Monitor.GetMaxTrace: Integer;
begin
Result := FMaxTrace;
end;
function TV2Monitor.GetMonitorEnabled: Boolean;
begin
Result := Active;
end;
procedure TV2Monitor.SaveToFile(FileName: String);
begin
slSQL.SaveToFile( FileName );
end;
procedure TV2Monitor.SetMaxTrace(const Value: Integer);
begin
FMaxTrace := Value;
end;
procedure TV2Monitor.SetMonitorEnabled(const Value: Boolean);
begin
Active := Value;
end;
Kind Regards,
Robert.
