(*  TMessageTracer v. 1.06
    Copyright (c) 1998-2003 by CoolDev.Com.
    Delphi 3/4/5/6/7
    C++Builder 3/4/5/6

    Although TMessageTracer is being distributed as Freeware with full
    source codes included, IT IS part of CoolControls package and
    should be delivered un-modified ONLY togeather with CoolControls.
*)

{$I versions.inc}
unit VclTracerReg;

interface

uses
  Windows, Messages, Classes, Controls, CoolCtrls, SysUtils, Forms,
  {$IFNDEF DELPHI6_OR_ABOVE}
  DsgnIntf
  {$ELSE}
  DesignIntf,
  DesignEditors
  {$ENDIF}
  ;

type
  {TGlobalWinControlProperty}
  TGlobalWinControlProperty = class(TComponentProperty)
  public
    procedure GetValues(Proc: TGetStrProc); override;
    function GetAttributes: TPropertyAttributes; override;
  end;

  {TMessageTracerEditor}
  TMessageTracerEditor = class(TDefaultEditor)
  public
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
    procedure Edit; override;
  end;

procedure Register;

implementation

uses
  MsgTracer, VclTracer;

{TGlobalWinControlProperty}
procedure TGlobalWinControlProperty.GetValues(Proc: TGetStrProc);
begin
  {$IFNDEF DELPHI6_OR_ABOVE}
  Proc(Designer.Form.Name);
  {$ELSE}
  Proc(IDesignerHook(Designer.AncestorDesigner).Form.Name);
  {$ENDIF}
  inherited GetValues(Proc);
end;

function TGlobalWinControlProperty.GetAttributes: TPropertyAttributes;
begin
  Result := inherited GetAttributes + [paValueList]
end;

{TMessageTracerEditor}
procedure TMessageTracerEditor.ExecuteVerb(Index: Integer);
begin
  if Index = 0 then
    TMessageTracer(Component).Execute;
end;

function TMessageTracerEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0: Result := 'Messages Tracer...';
  end;
end;

function TMessageTracerEditor.GetVerbCount: Integer;
begin
  Result := 1
end;

procedure TMessageTracerEditor.Edit;
begin
  TMessageTracer(Component).Execute;
end;

procedure Register;
begin
  RegisterComponents('CoolControls Tools', [TMessageTracer]);
  RegisterPropertyEditor(TypeInfo(TWinControl), TMessageTracer, 'Control', TGlobalWinControlProperty);
  RegisterComponentEditor(TMessageTracer, TMessageTracerEditor);
end;

end.