On 05/01/2014 23:50, Alejandro Gonzalo wrote:
For example, if you want to loop though components and set the
dbNavigator's DataSource property to that of the component if it has a
DataSource property (and of course is not a dbNavigator itself).  It
seems you can't do that by using the component's hierarchy.  Is there
someway else to do that?  Components do seem to have HasHelp and
HasParent properties already.

Something like this:

uses typinfo;

function ComponentHasProperty(aComponent: TComponent; aProperty: string): boolean;
begin
  if not Assigned(aComponent) or (aProperty='') then
    Exit(False);
  Result:=GetPropInfo(aComponent, aProperty)<>nil;
end;

function ClassHasProperty(aClass: TClass; aProperty: string): boolean;
begin
  if (aProperty='') then
    Exit(False);
  Result:=GetPropInfo(aClass, aProperty)<>nil;
end;


--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to