procedure GetProperties(Objet: TObject; Items: TStrings); var iI : integer; PropList : TPropList; Scope, AName : string; begin AName := GetPropInfo(Objet, 'Name')^.Name; iI := 0; GetPropList(Objet.ClassInfo, tkProperties + [tkMethod], @PropList); Items.Add( AName +' Class : '+ Objet.ClassName); Items.Add('----------------------'); while ((nil <> PropList[iI]) and (iI < High(PropList))) do begin Scope := IfThen(IsPublishedProp(Objet, PropList[iI].Name), ' (Published)'); Scope := Scope + Ifthen(IsStoredProp(Objet, PropList[iI].Name), ' (Stored)'); Items.Add(PropList[iI].Name + ' : ' + PropList[iI].PropType^.Name + Scope); inc(iI); end; end;
procedure TForm1.btnGetInfosClick(Sender: TObject); begin Memo1.Clear; Memo1.Lines.BeginUpdate; GetProperties(Memo1, Memo1.Lines); Memo1.Lines.EndUpdate; end;
Name Class : TMemo ---------------------- Align : TAlign (Published) (Stored) Alignment : TAlignment (Published) (Stored) Anchors : TAnchors (Published) BevelEdges : TBevelEdges (Published) (Stored) BevelInner : TBevelCut (Published) (Stored) BevelKind : TBevelKind (Published) (Stored)
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionAName := GetPropInfo(Objet.ClassInfo, 'Name')^.Name;
procedure GetPropertiesD4(Objet: TObject; Items: TStrings); var PropList: PPropList; i: integer; AName: String; begin PropList := AllocMem(SizeOf(PropList^)); AName := GetPropInfo(Objet.ClassInfo, 'Name')^.Name; i := 0; try GetPropList(Objet.ClassInfo, tkProperties + [tkMethod], PropList); Items.Add( AName +' Class : '+ Objet.ClassName); Items.Add('----------------------'); while (PropList^[i] <> Nil) and (i < High(PropList^)) do begin Items.Add(PropList^[i].Name + ': ' + PropList^[i].PropType^.Name); Inc(i); end; finally FreeMem(PropList); end; end;
procedure TForm1.Button1Click(Sender: TObject); begin Memo1.Clear; Memo1.Lines.BeginUpdate; GetPropertiesD4(Memo1, Memo1.Lines); Memo1.Lines.EndUpdate; end;