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