Am creating new Shape Component ,its name : Device Shape , but the component didn't registered and its not appear in the components plate.
The code were compiled without any errors , but I could not register the new component .
can anybody help.
unit DeviceShape;
interface
uses
SysUtils, Windows, Classes,
Graphics, Controls,ExtCtrls;
type
TdeviceType=(Smoke,Heat,Control_Module,Monitor_Module,Bell,Break_Glass,Sirin);
TdeviceShape=class(TShape)
private
FDevType:TdeviceType;
FdeviceTxt:string;
procedure SetDeviceTxt(Value:String);
procedure SetDeviceType (Value:TdeviceType);
public
constructor Create (AOwner: TComponent); override;
protected
procedure Paint; override ;
published
property Text: string read FdeviceTxt write SetDeviceTxt default 'S' ;
property DeviceType:TdeviceType read FDevType write SetDeviceType default Smoke;
property OnClick;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
end;
procedure register ;
implementation
procedure Register;
begin
RegisterComponents('Issam', [TdeviceShape]);
end;
and here you can find the next procedures body :
procedure TdeviceShape.Paint;
begin
Canvas.Font.Height:=Width-(Width div 4) ;
Canvas.TextOut(0,(Height div 2)-(Canvas.Font.Height div 2),FdeviceTxt);
inherited;
end;
procedure TdeviceShape.SetDeviceTxt(Value:String);
begin
case FDevType of
Smoke : FdeviceTxt:='S';
Heat : FdeviceTxt:='H';
Control_Module : FdeviceTxt:='C';
Monitor_Module : FdeviceTxt:='M';
Bell : FdeviceTxt:='B';
Break_Glass : FdeviceTxt:='BG';
Sirin : FdeviceTxt:='SI' ;
end;
Invalidate;
end;
procedure TdeviceShape.SetDeviceType(Value: TdeviceType);
begin
if FDevType <> Value then
begin
FDevType := Value;
Invalidate;
end;
end;
end.
From the documentation on registering components:
Registration involves writing a single procedure in a unit of your package, which must have the name Register. The Register procedure must appear in the interface part of your unit, and (unlike the rest of Delphi) its name is case-sensitive.
Note: Although Delphi is a case-insensitive language, the Register procedure is case-sensitive and must be spelled with an uppercase
R
.
So it seems like you need to write Register
instead of register
in the interface section.