RTTI Information

I have a panel with custom TDataSource property.
I want to checked every dropped component, if it has DataSource property, and if so, then fill it.
Now, how can i do that? I know i have to use getpropinfo, and setordprop but it works only with integers and not classes/objects.
Any solutions?
LVL 1
fulg0reAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MadshiCommented:
Well, it works for classes/objects, too, because classes/objects are just pointers and pointers are 4 byte long, like ordinals. You only need to typecast.

Regards, Madshi.
0
RadlerCommented:
Hi people;

I saw a interesting bit of code at VCL
procedure TWriter.WriteProperties(Instance: TPersistent);
var
  I, Count: Integer;
  PropInfo: PPropInfo;
  PropList: PPropList;
begin
  Count := GetTypeData(Instance.ClassInfo)^.PropCount;
  if Count > 0 then
  begin
    GetMem(PropList, Count * SizeOf(Pointer));
    try
      GetPropInfos(Instance.ClassInfo, PropList);
      for I := 0 to Count - 1 do
      begin
        PropInfo := PropList^[I];
        if PropInfo = nil then break;
        if IsStoredProp(Instance, PropInfo) then
          WriteProperty(Instance, PropInfo);
      end;
    finally
      FreeMem(PropList, Count * SizeOf(Pointer));
    end;
  end;
  Instance.DefineProperties(Self);
end;

but my free time dont permmit a detailed answer, but this seems promissor.

T++, Radler.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
simonetCommented:
Hmmmm. 50 points (easy) for this question is kinda low. After all, this isn't an everyday question. It's a little harder than that.

I'll post the answer if you raise the points to the appropritate level this question deserves.

Alex
0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

MadshiCommented:
:-)  Alex, it seems that you didn't like the "42" answer...   (-:
0
interCommented:
Hi,

if gentlemens do not mind I have an answer.
0
simonetCommented:
If it was to post an answer almost for free, I'd have done it last night, Barry.

Well, "42" wasn't an option here, right?
0
MadshiCommented:
Alex, you're talking with inter/igor, not with inthe/Barry...   :-))
0
interCommented:
Ok then, I do not want to mess up the bargaining...
0
simonetCommented:
Ops... I guess I getta get back to wear my glasses! Sorry for the confusion, Igor.

Alex
0
interCommented:
No problem friend ;-)
0
fulg0reAuthor Commented:
guys, why bargan? this is just exchange...
btw. this example is a correct one.
10x
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.