问题描述
正在创建新的形状组件,其名称为:设备形状,但该组件未注册且未出现在组件面板中。
代码编译没有任何错误,但我无法注册新组件。
谁能帮忙。
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.
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)