【发布时间】:2021-05-02 05:17:48
【问题描述】:
正在创建新的形状组件,它的名称:设备形状,但该组件没有注册并且它没有出现在组件板中。
代码编译没有任何错误,但我无法注册新组件。
谁能帮忙。
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.
【问题讨论】:
-
你把它放在包里了吗?你有
Register程序吗?你安装包了吗? -
是的。抱歉,我已尝试附上代码...但该网站要求提供更多详细信息..
-
好吧,那么您应该听从建议并提供更多详细信息。所有相关代码(尤其是
Register过程),以及您尝试安装组件的如何的描述:单元、包、方法(例如右键单击包并选择“安装”) ,以及所发生情况的描述:显示的消息文本。 -
我已经减少了附加代码..
标签: delphi components shapes