创建新的 Tshape 组件问题,Delphi 7
Creating new Tshape component problem ,Delphi 7
正在创建新的 Shape 组件,其名称为:Device Shape,但该组件未注册且未出现在组件面板中。
代码编译没有任何错误,但我无法注册新组件。
谁能帮忙。
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;
在这里您可以找到下一个程序正文:
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.
来自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
.
所以看起来你需要在界面部分写Register
而不是register
。
正在创建新的 Shape 组件,其名称为:Device Shape,但该组件未注册且未出现在组件面板中。
代码编译没有任何错误,但我无法注册新组件。
谁能帮忙。
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;
在这里您可以找到下一个程序正文:
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.
来自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
.
所以看起来你需要在界面部分写Register
而不是register
。