tag属性是干什么用的

解决方案 »

  1.   

    TAG是個還沒有用到的屬性不過你可以自己來管理
      

  2.   

    就一个预定义的标记字段;
    可以用来标记控件在单元或者在整个系统的编号;我习惯上将它定义为一个7位的数字;0-1位代表控件所属的模块编号;
    2-3位代表单元在模块中的编号;
    4-6位代表控件在单元中的编号;
    而tag为0时则默认为不需要代码处理的事件:procedure TFrmMain.InitSystem;
    var I,J: integer;
    begin
    //初始化ToolButton, TMenuItem控件的点击的点击事件
      for I := 0 to FrmMain.ComponentCount - 1 do
      with  FrmMain.Components[I] do
      begin
        if (Tag <> 0) and (ClassType <> nil) then
        begin
          if ClassName = 'TMenuItem' then   //Menuitem菜单条的单击事件
          begin
             if  TmenuItem(FrmMain.Components[I]).GroupIndex = 1 then
             TmenuItem(FrmMain.Components[I]).OnClick := ActCreateFormExecute;
          end;
        end;
      end;
    end;