Feras em criação de componentes

Delphi

28/02/2003

Fiz isso e como eu agora faço para instalar este componente?

unit DBNavHav;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, DBCtrls, Buttons;

type
TDBNavHav = class(TDBNavigator)
private

FCaptions: TStrings;
FHints : TStrings;
FLayout : TButtonLayout;
FSpacing : Integer;
FMargin : Integer;

protected

procedure SetCaptions(value: TStrings);
procedure SetLayout(value: TButtonLayout);
procedure SetSpacing(value: integer);
procedure SetMargin(value: integer);

public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;

published

property Captions: TStrings read FCaptions write SetCaptions;
property Layout: TButtonLayout read FLayout write SetLayout default blGlyphTop;
property Spacing: Integer read FSpacing write SetSpacing default 2;
property Margin: Integer read FMargin write SetMargin default -1;
property Font;
property Hints;



end;

procedure Register;

implementation

constructor TDBNavHav.Create(AOwner: TComponent);
var
X : Integer;

begin
inherited Create(AOwner);

FLayout:= blGlyphTop;
FSpacing:= 2;
FMargin:= -1;

FCaptions:= TStringList.Create;
FCaptions.Clear;
FCaptions.Add(´Primeiro´);
FCaptions.Add(´Retorna´);
FCaptions.Add(´Avança´);
FCaptions.Add(´Último´);
FCaptions.Add(´Novo´);
FCaptions.Add(´Exclui´);
FCaptions.Add(´Altera´);
FCaptions.Add(´Salva´);
FCaptions.Add(´Cancela´);
FCaptions.Add(´Atualiza´);

FHints := TStringList.create;
FHints.Clear;
FHints.Add(´Ctrl+P´);
FHints.Add(´Ctrl+R´);
FHints.Add(´Ctrl+A´);
FHints.Add(´Ctrl+U´);
FHints.Add(´Ctrl+N´);
FHints.Add(´Ctrl+E´);
FHints.Add(´Ctrl+L´);
FHints.Add(´Ctrl+S´);
FHints.Add(´Ctrl+C´);
FHints.Add(´Ctrl+Z´);

ShowHint := True;
Height := 40;
Width := 500;
Font.Name := ´Arial´;
Font.Size := 8;
Hints := FHints;

for X := 0 to ComponentCount - 1 do
begin

if Controls[x] is TNavButton then
begin

with Controls[x] as TNavButton do
begin

if integer(index) < FCaptions.Count then
Caption := FCaptions[integer(index)]
else
Caption := ´?´;

Layout := FLayout;
Spacing := FSpacing;

end;
end;
end;

Invalidate;

end;

{******************************************************************************}

destructor TDBNavHav.Destroy;
begin

FCaptions.Free;
FHints.Free;

inherited Destroy;

end;

{******************************************************************************}

procedure TDBNavHav.SetCaptions(Value: TStrings);
var

x: integer;

begin

FCaptions.Assign(Value);

for x := 0 to ComponentCount - 1 do
begin

if Controls[x] is TNavButton then
begin

with Controls[x] as TNavButton do
begin

if integer(index) < FCaptions.Count then
Caption := FCaptions[integer(index)]
else
Caption := ´´;

end;

end;

end;

Invalidate;

end;

{***********************************************************}

procedure TDBNavHav.SetLayout(value: TButtonLayout);
var

x: integer;

begin

FLayout := value;

for x := 0 to ComponentCount - 1 do
begin

if Controls[x] is TNavButton then
begin

with Controls[x] as TNavButton do Layout := value;

end;

end;

Invalidate;

end;

{******************************************************************************}

procedure TDBNavHav.SetSpacing(value: integer);
var

x: integer;

begin

FSpacing := value;

for x := 0 to ComponentCount - 1 do
begin

if Controls[x] is TNavButton then
begin

with Controls[x] as TNavButton do
Spacing := value;

end;

end;

Invalidate;

end;

{******************************************************************************}

procedure TDBNavHav.SetMargin(value: integer);
var

x: integer;

begin

FMargin := value;

for x := 0 to ComponentCount - 1 do
begin

if Controls[x] is TNavButton then
begin

with Controls[x] as TNavButton do
margin := value;

end;

end;

Invalidate;

end;


{******************************************************************************}


procedure Register;
begin
RegisterComponents(´Havilux´, [TDBNavHav]);
end;



end.


Havilux

Havilux

Curtidas 0

Respostas

Anonymous

Anonymous

28/02/2003

Dentro da unit, vc tem que ter um procedimento
[b:06af584084]Register[/b:06af584084] nele vc chama a funcao ´RegisterComponents´

falow[/b]


GOSTEI 0
POSTAR