delphi2007 教程

delphi2007 教程

首页 新随笔 联系 聚合 管理
  1013 Posts :: 0 Stories :: 28 Comments :: 0 Trackbacks
请各位大虾帮我看看,这句是什么意思? Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiBase/html/delphi_20061217220452133.html
此段代码为书中的例子的一部分代码,讲的是用类引用类型动态创建控件,其中有一句代码不明白其含义,请各位大虾赐教!  
   
  procedure   TMainForm.PanelContainerMouseDown(Sender:   TObject;  
      Button:   TMouseButton;   Shift:   TShiftState;   X,   Y:   Integer);  
  var  
      NewControl:   TControl;  
      NewControlName:   string;  
  begin  
      if   Button   =   mbLeft   then  
      begin  
          NewControl   :=   FControlClassRef.Create(Self);     //   创建部件对象  
          NewControl.Parent   :=   Self.PanelContainer;     //   设置部件的宿主  
          NewControl.Visible   :=   false;     //   隐藏部件  
          NewControl.Left   :=   X;     //   设置部件的位置坐标  
          NewControl.Top   :=   Y;     //   设置部件的位置坐标  
          Inc(FControlClassCount);     //   计数器增1  
          NewControlName   :=   FControlClassRef.ClassName()   +   IntToStr(FControlClassCount);  
          Delete(NewControlName,   1,   1);     //   这句是什么意思呢?好象删除对程序没影响.  
          NewControl.Name   :=   NewControlName;     //   设置部件名称  
          NewControl.Visible   :=   true;     //   显示部件  
      end;  
  end;  
 

Delete(NewControlName,   1,   1);     //   这句是什么意思呢?好象删除对程序没影响.  
  ===================================================================================  
  这句话是在确定控件名称的时候,去掉前面的'T'。比如控件是TEdit,FControlClassCount=1,  
  NewControlName   :=   FControlClassRef.ClassName()   +   IntToStr(FControlClassCount);  
  就会是‘TEdit1’,去掉'T',NewControlName就等于'Edit1'

Delete(NewControlName,   1,   1);     补充:这个调用是删除NewControlName这个字符串的第一个字符。

to   maozefa(阿发伯):  
  谢谢!!

posted on 2008-10-14 16:34 delphi2007 阅读(82) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。