como instalar um component novo no delphi?

Delphi

28/06/2003

Oi pessoal. Gostaria de saber como faço para instalar um componente novo. Baixei ele de um site, mas só veio o *.pas.
Definiçoes do dito cujo:
Ele é um multigrid, derivado da classe tstringgrid, com a facilidade de vc poder definir o tamanho e cor de cada celula individualmente.
Desde já agradeço a colaboração de vocês :lol:
Aqui esta o dito cujo:
// by Fernando Sarturi Prass - FREEWARE
//e-mail: prass@pro.via-rs.com.br
// home page: http://www.fprass.hpg.com.br

unit MultiGrid;

interface

uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, Grids;

type
TVerticalAlignment = (vaTop, vaCenter, vaBottom);
TMultiGridAlignmentEvent=procedure(Sender:TObject;ARow,ACol:LongInt;
var HorAlignment:TAlignment;
var VerAlignment:TVerticalAlignment) of object;
TMultiGridColorEvent=procedure(Sender:TObject;ARow,Acol:LongInt;
AState:TGridDrawState;ABrush:TBrush;AFont:TFont) of object;
TMultiGrid = class(TStringGrid)
private
FAlignment : TAlignment;
FVerticalAlignment : TVerticalAlignment;
FMultiLinea : Boolean;
FOnGetCellAlignment : TMultiGridAlignmentEvent;
FOnGetCellColor : TMultiGridColorEvent;
procedure SetAlignment(Valor : TAlignment);
procedure SetVerticalAlignment(Valor : TVerticalAlignment);
procedure SetMultiLinea(Valor : Boolean);
protected
procedure DrawCell(ACol,ARow : LongInt; ARect : TRect;
AState : TGridDrawState); override;
public
constructor Create(AOwner : TComponent); override;
published
property Alignment : TAlignment read FAlignment write SetAlignment
default taLeftJustify;
property VerticalAlignment : TVerticalAlignment read
FVerticalAlignment write SetVerticalAlignment default vaCenter;
property MultiLinea : Boolean read FMultiLinea write
SetMultiLinea default False;
property OnGetCellAlignment : TMultiGridAlignmentEvent read
FOnGetCellAlignment write FOnGetCellAlignment;
property OnGetCellColor : TMultiGridColorEvent read
FOnGetCellColor write FOnGetCellColor;
property Options default [goFixedVertLine, goFixedHorzLine,
goVertLine, goHorzLine, goRangeSelect, goRowSizing,
goColSizing];
end;

procedure Register;

implementation

constructor TMultiGrid.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
FAlignment:=taLeftJustify;
FVerticalAlignment:=vaCenter;
{FColor:=clWindowText;}
FMultiLinea:=False;
Options:=[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,
goRangeSelect,goRowSizing,goColSizing];
end;

procedure TMultiGrid.SetAlignment(Valor : TAlignment);
begin
if valor <> FAlignment then
begin
FAlignment:=Valor;
Invalidate;
end;
end;

procedure TMultiGrid.SetVerticalAlignment(Valor : TVerticalAlignment);
begin
if valor <> FVerticalAlignment then
begin
FVerticalAlignment:=Valor;
Invalidate;
end;
end;

procedure TMultiGrid.SetMultiLinea(Valor : Boolean);
begin
if valor <> FMultiLinea then
begin
FMultiLinea:=Valor;
Invalidate;
end;
end;

procedure TMultiGrid.DrawCell(ACol,ARow : LongInt; ARect : TRect;
AState : TGridDrawState);
Const
TextAlignments : Array[TAlignment] of Word = (dt_Left, dt_Right,
dt_Center);
Var
HorAlineacion : TAlignment;
VerAlineacion : TVerticalAlignment;
Texto : string;
Altura : integer;
CRect : TRect;
opciones : integer;
begin
Texto:=Cells[ARow,Acol];
HorAlineacion:=FAlignment;
VerAlineacion:=FVerticalAlignment;
if Assigned(FOnGetCellAlignment) then
FOnGetCellAlignment(Self,ARow,ACol,HorAlineacion,VerAlineacion);
if Assigned(FOnGetCellColor) then
FOnGetCellColor(Self,ARow,ACol,AState,Canvas.Brush,Canvas.Font);
Canvas.FillRect(ARect);
Inc(ARect.Left,2);
Dec(ARect.Right,2);
CRect:=Arect;
opciones:=TextAlignments[HorAlineacion] or dt_VCenter;
if Multilinea then
opciones:=opciones or dt_WordBreak;
if not DefaultDrawing then
inherited DrawCell(ACol,ARow,ARect,AState)
else
with ARect,Canvas do
begin
Altura:=DrawText(Handle,PChar(Texto),-1,CRect,opciones or
dt_CalcRect);
if FVerticalAlignment = vaCenter then
begin
if Altura < Bottom-Top+1 then
begin
Top:=(Bottom+Top-Altura) shr 1;
Bottom:=Top+Altura;
end;
end
else
if FVerticalAlignment = vaBottom then
if Altura < Bottom-Top+1 then
Top:=Bottom-Altura;
DrawText(Handle,PChar(Texto),-1,ARect,opciones)
end;
end;

procedure Register;
begin
RegisterComponents(´Prass´, [TMultiGrid]);
end;

end.


Cal

Cal

Curtidas 0

Respostas

Michel_prog

Michel_prog

28/06/2003

Caro colega para vc instalar novo componete você tem que fazer o seguinte.
Em file-new-other
Lá Procure Packpages de um click
então em add procure o arquivo *.pas e click Ok e depois copile beleza esta rodando seu componente beleza
Michel gibin
System Technology
Duvidas falecom_michel@yahoo.com.br


GOSTEI 0
Michel_prog

Michel_prog

28/06/2003

Copilei seu codigo e funcionou coretamente do delhpi 7


GOSTEI 0
Cal

Cal

28/06/2003

Valeu mano. muito obrigado. :lol:


GOSTEI 0
POSTAR