Delphi中已删除控件的默认命名
当我在设计时在窗体上添加新控件时,Delphi会给它们默认名称Delphi中已删除控件的默认命名,delphi,delphi-10.2-tokyo,Delphi,Delphi 10.2 Tokyo,当我在设计时在窗体上添加新控件时,Delphi会给它们默认名称TLabel控件将命名为'Label1','Label2'等 我创建了自己的组件类:tMyLabel。注意小写的t。Delphi将这些控件命名为'tMyLabel1','tMyLabel2',等等。我不希望在开头使用't' 我意识到这与类名有关。在这种情况下,Delphi似乎区分大小写 如果我将我的类重命名为TMyLabel,那么一切都很好 为什么德尔福在这件事上区分大小写?我能否说服Delphi不区分'tMyLabel'和'tMyL
TLabel
控件将命名为'Label1'
,'Label2'
等
我创建了自己的组件类:tMyLabel
。注意小写的t
。Delphi将这些控件命名为'tMyLabel1'
,'tMyLabel2'
,等等。我不希望在开头使用't'
我意识到这与类名有关。在这种情况下,Delphi似乎区分大小写
如果我将我的类重命名为TMyLabel
,那么一切都很好
为什么德尔福在这件事上区分大小写?我能否说服Delphi不区分'tMyLabel'
和'tMyLabel'
我使用Delphi10.2.3,但Delphi多年来一直采用这种方式
编辑(2018-04-30):
肯要一个密码
unit MySpeedButton;
interface
uses
SysUtils, Classes, Controls, Vcl.Graphics, Buttons;
type
tMySpeedButtonProps = class(TPersistent)
private
fParent : pointer ;
constructor Create( pParent : pointer );
destructor Destroy; override;
end;
type
tMySpeedButton = class( TSpeedButton )
private
fMyProps : tMySpeedButtonProps ;
protected
procedure Click ; override;
public
function GetCanvas: TCanvas; //Allow access to the Canvas procedure Paint ; override ;
constructor Create( AOwner : TComponent ); override;
destructor Destroy; override;
published
property TM : tMySpeedButtonProps read fMyProps write fMyProps;
end;
procedure Register;
implementation
uses
Forms, Windows;
constructor tMySpeedButtonProps.Create( pParent : pointer );
begin
inherited Create;
fParent := pParent ;
end;
destructor tMySpeedButtonProps.Destroy;
begin
inherited Destroy;
end;
constructor tMySpeedButton.Create(AOwner: TComponent);
begin
fMyProps := tMySpeedButtonProps.Create( self );
inherited Create(AOwner);
{$ifdef RegisterFormular }
{$endif}
end;
destructor tMySpeedButton.destroy;
begin
fMyProps.Free;
inherited destroy;
end;
procedure tMySpeedButton.Click ;
begin
inherited Click;
end;
procedure tMySpeedButton.Paint ;
begin
inherited Paint;
end;
function tMySpeedButton.GetCanvas: TCanvas;
begin
Result:= Canvas;
end;
procedure Register;
begin
RegisterComponents( 'Test' , [ tMySpeedButton ] );
end;
end.
编译并注册
tMySpeedButton
后,我得到了以“t”开头的不需要的名称。Delphi(语言)不区分大小写。这东西是。为什么?因为有人决定了吗?:)与寄存器
过程类似。这也必须是大写的。通常Delphi中区分大小写的部分是因为需要与C++Builder兼容。Delphi不区分大小写,只有一个例外。该异常是用于注册组件的Register
过程的名称,它区分大小写的唯一原因是为了与C++Builder兼容。Delphi的标准(以及绝大多数Delphi开发人员、组件库和世界上大多数使用Turbo Pascal派生版本的其他人的标准)是在类型名称前面加上大写的T
,如TLabel
,TForm
,等等。Delphi自1.0版发布以来就已经这样做了,今天也继续这样做。(续)Delphi也不会产生您描述的行为,我使用了几十个内部创建的组件,它们的行为正常-一个类名为TMyLabel
的标签变成MyLabel1
,一个快速测试表明,当将tMyLabel
类放到表单上时,它仍然会变成MyLabel1
。请提供一个示例组件源文件(可以复制/粘贴到IDE中,放置到包中,然后进行编译)来演示该问题。我怀疑你错给你的班级起了不同的名字(比如TtMyLabel
)。@Ken:我已经撤回了我的评论。