动态生成一个设定好特殊样式的Tlabel,快速生成代码;
1、自己先在可视化界面设定一个Label,像这样:
2、选择label,快捷键ctrl+C 复制,粘贴带代码编辑器去,会生成一段这样的窗体代码;
object lbl1: TLabel
Left =
Top =
Width =
Height =
Align = alLeft
Alignment = taCenter
Caption = ' '#########'GPS'######
Color =
Font.Charset = GB2312_CHARSET
Font.Color = clWhite
Font.Height = -
Font.Name = ####
Font.Style = []
ParentColor = False
ParentFont = False
Layout = tlCenter
ExplicitHeight =
end
3、在代码里面修改一下即可,修改成:
fProjName :TLabel;//定义 {$IFDEF GuangXiNanTie}
fProjName :=TLabel.Create(self);
with fProjName do
begin
Parent :=Self;
Left := ;
Top := ;
//Width = 289
//Height = 47
Align := alLeft;
Alignment := taCenter;
Caption :=' 中国移动广西公司GPS指挥调度平台';
Color := $00FDFDFD;
Font.Charset := ANSI_CHARSET;
Font.Color := $00FDFDFD;
Font.Height := -;
Font.Name := ####;
Font.Style := [];
ParentColor := False;
ParentFont := False;
Layout := tlCenter ;
//ExplicitHeight = 19
end;
{$ENDIF}
拓展:DEFINE的用法 :定义在文件头,Interface之前,只能在本单元生效,举例:
unit uTitleBar;
//{$DEFINE GuangXiNanTie}
interface