Go Back   Wiki NewForum | Latest Entertainment News > Career Forum & Tips > Tech Forum & Tutorial > Oracle Database, SQL, Application, Programming


Your own object inspector


Reply
Views: 1519  
Thread Tools Rate Thread
  #1  
Old 08-09-2010, 01:11 PM
bholas bholas is offline
Award Winner
 
Join Date: Apr 2010
Posts: 4,977
Default Your own object inspector

We all like the "Object Inspector" for its ease of use and all the information it can provide. Wouldn't it be great to have your own possibly non-visual object inspector available at run time -- so you can find out which properties and methods a given object (or component) may have and what type these properties are? Try this:
uses TypInfo;

procedure ObjectInspector(
Obj : TObject;
Items : TStrings );
var
n : integer;
PropList : TPropList;
begin
n := 0;
GetPropList(
Obj.ClassInfo,
tkProperties + [ tkMethod ],
@PropList );
while( (Nil <> PropList[ n ]) and
(n < High(PropList)) ) do
begin
Items.Add(
PropList[ n ].Name + ': ' +
PropList[ n ].PropType^.Name );
Inc( n );
end;
end;
For example, let's say you want to get information about a listbox named "ListBox1" and store the information in the same "ListBox1"
ObjectInspector( ListBox1, ListBox1.Items );

Reply With Quote
Reply

Tags
programming tips

New topics in Oracle Database, SQL, Application, Programming





Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
WikiNewForum)