如何得到一个一个控件(如:BUTTON,LABLEL等)的《所有属性》和所有属性的全部可能取值?多谢!!!!

解决方案 »

  1.   

    DELPHI的帮助F1帮助主题输入要找的控件名
      

  2.   

    这样
      for I:=0 to componentcount-1 do
          if components[I] is TButton then
             TButton(components[I]).enabled:=true;
          if components[I] is TLABLEL then
             TLABLEL(components[I]).enabled:=true;
    如此而已
      

  3.   

    我需要的是用程序读出 一个一个控件(如:BUTTON,LABLEL等)的《所有属性》和所有属性的全部可能取值?
      

  4.   

    to kataboy(小浩子) 
    谢谢
    我在设计一个在运行期可以调整得应用
      

  5.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      Pclass :PTypeInfo;
      PClasstd :PTypeData;  ppi :PPropInfo;  i, j:Integer;
      ptd :PTypeData;  RowIndex :Integer;  tmpProps :PPropList;
      tmpCount :Integer;  tmpValue :Variant;
      FnPropCount :Integer;
        FPProps  :PPropList;    //当前编辑的属性列表  FControl :TObject;
    begin
      FControl := xx;      PClass := PTypeInfo(FControl.ClassInfo);
          //得到控件信息
          if PClass^.Kind = tkClass then begin  //如果是类
            PClasstd := GetTypeData(PClass);      //得到TypeData
            FnPropCount := PClasstd^.PropCount;
            if FnPropCount > 0 then begin
              GetMem(FPProps, sizeof( PPropInfo) * FnPropCount);  //分配内存          GetPropInfos(PClass, FPProps);   //得到所有的属性
            end;
          end;
          //得到第一个控件的所有属性,并放入到FPProps中
          for i := 0 to FnPropCount - 1 do
          begin
            pPi := FpProps[i];        if Assigned(Ppi) then begin
              if {inStringArray(ifo_gPropClasses, ppi.PropType^.Name)
                or inStringArray(ifo_gProps, ppi.Name)} True then
              begin
                Self.Memo1.Lines.Add(ppi.Name + ' - ' + ppi.PropType^.Name + ' - ' + ppi.Name);
                case ppi.PropType^.Kind of
                  tkLString:begin
                    tmpValue := GetStrProp(FControl, ppi.Name);
                    Self.Memo1.Lines.Add('  ' + tmpValue);
                  end;
                  tkInteger:begin
                    tmpValue := GetOrdProp(FControl, ppi.Name);
                    Self.Memo1.Lines.Add('  ' + IntToStr(tmpValue));              end;
                  tkClass:begin
                    if ppi.PropType^.Name = TFont.ClassName then begin
                      Self.Memo1.Lines.Add('  ' + '(TFont)');
                    end;
                  end;
                  tkEnumeration:begin
                  end;
                end;            end;
              end;
            end;
    //    Self.PropGridSelectCell(nil, FForm.sgrdEdit.Col,
    //        FForm.sgrdEdit.Row, tmpbool);
    end;
      

  6.   

    转自大富翁的!
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      Grids, StdCtrls,typinfo;type
      TForm1 = class(TForm)
        Button1: TButton;
        insp: TStringGrid;
        event: TStringGrid;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    var count,j,k,i : integer;
        proplist: PPropList;//
        Propinfo : PPropinfo;
    begin
      Count := GetTypeData(Sender.ClassInfo)^.PropCount;
      if Count > 0 then
      begin
        // 得到属性数
        GetMem(PropList, Count * SizeOf(PPropList));
        try
          // 得到属性
          GetPropInfos(Sender.ClassInfo, PropList);
          insp.RowCount:=count;
          event.RowCount:=count;
          j:=0;
          K:=0;
          for I := 0 to Count - 1 do
          begin
            PropInfo := PropList^[I];        case PropInfo.PropType^.kind of
            tkInteger,
            tkEnumeration :
              insp.cells[1,j]:= inttostr(getordProp(Sender,PropInfo));
            tkString,
            tkLString,
            tkWString :
              insp.cells[1,j]:= getstrProp(Sender,PropInfo);
            tkFloat :
              insp.cells[1,j]:=FloattoStr(GetFloatProp(Sender,PropInfo));
            tkMethod :
              event.cells[1,k]:='Event';
            else
              insp.cells[1,i]:='TYPE'+inttostr(ord(PropInfo.PropType^.kind));
            end;
             if PropInfo.PropType^.kind=tkMethod then
            begin
              event.cells[0,k]:=PropInfo.Name;
              k:=k+1
            end  
            else
            begin
              insp.cells[0,j]:=PropInfo.Name;
              j:=j+1;
            end;
          end;
          insp.RowCount:=j;
          event.RowCount:=k;
        finally
          FreeMem(PropList, Count * SizeOf(PPropList));
        end;
      end;
    end;
      

  7.   

    TO INeedCa(缺钙) 
    您的程序仅仅遍历了所有的属性,并没有给出这些属性的所有的取值,如:windowstate的值可能是:wsNormal,wsMaximized,wsMinimized