Romans
asked on
Component help
You know when you drop and 2 or 3 ImageLists on a form, and they show up in the object inspector for a ListView - LargeImage List ... for an example ..
Well how do i go about doing this with a component that I am creating? How do I access all the properties, methods and event of the imagelist?
Can somebody provide me with a good example of a component that does this.
Thanks
Well how do i go about doing this with a component that I am creating? How do I access all the properties, methods and event of the imagelist?
Can somebody provide me with a good example of a component that does this.
Thanks
Have a look at TypInfo unit which contains utility functions to access RTTI (run-time type information). Delphi generates RTTI automatically (unless you turn it off with a compiler directive) for all published properties of any TPersistent descendant.
HTH
TOndrej
HTH
TOndrej
I think I know what you mean.
If you declare a property like this
property Images: TImageList read FImageList write FImageList;
In your code do this
if Assigned(Images) then
Images.Whatever;
Here are some tips !!
1) When you refer to an object, always check for the object being destroyed;
(In your component)
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
Then....
procedure TMyComponent.Notification( AComponent : TComponent; Operation: TOperation); override;
begin
inherited;
if (Operation = opRemove) and (AComponent = FImages) then Images := nil;
end;
2) You are only notified of components on the same form being destroyed unless you specifically ask the component to notify you.
procedure SetImages(Value: TImageList);
property Images: TImageList read FImages write SetImages;
Then...
procedure TMyComponent.SetImages(Val ue: TImageList);
begin
if Assigned(Images) then Images.RemoveFreeNotificat ion(Self);
FImages := Value;
if Assigned(Images) then Images.FreeNotification(Se lf);
end;
There are 2 component-writing articles on my web site www.HowToDoThings.com covering basics + properties of this sort.
http://www.howtodothings.com/showarticle.asp?article=310
and
http://www.howtodothings.com/showarticle.asp?article=320
Pete
====
http://www.HowToDoThings.com (Delphi articles)
http://www.Stuckindoors.com/delphi (Graphics, Sound, etc, open-source)
If you declare a property like this
property Images: TImageList read FImageList write FImageList;
In your code do this
if Assigned(Images) then
Images.Whatever;
Here are some tips !!
1) When you refer to an object, always check for the object being destroyed;
(In your component)
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
Then....
procedure TMyComponent.Notification(
begin
inherited;
if (Operation = opRemove) and (AComponent = FImages) then Images := nil;
end;
2) You are only notified of components on the same form being destroyed unless you specifically ask the component to notify you.
procedure SetImages(Value: TImageList);
property Images: TImageList read FImages write SetImages;
Then...
procedure TMyComponent.SetImages(Val
begin
if Assigned(Images) then Images.RemoveFreeNotificat
FImages := Value;
if Assigned(Images) then Images.FreeNotification(Se
end;
There are 2 component-writing articles on my web site www.HowToDoThings.com covering basics + properties of this sort.
http://www.howtodothings.com/showarticle.asp?article=310
and
http://www.howtodothings.com/showarticle.asp?article=320
Pete
====
http://www.HowToDoThings.com (Delphi articles)
http://www.Stuckindoors.com/delphi (Graphics, Sound, etc, open-source)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yep, Ivo beat me on that one :)
But I still recommend reading those articles, especially as now part 3 has been added too !
http://www.howtodothings.com/showarticle.asp?article=327
Pete
====
http://www.HowToDoThings.com (Delphi articles)
http://www.Stuckindoors.com/delphi (Graphics, Sound, etc, open-source)
But I still recommend reading those articles, especially as now part 3 has been added too !
http://www.howtodothings.com/showarticle.asp?article=327
Pete
====
http://www.HowToDoThings.com (Delphi articles)
http://www.Stuckindoors.com/delphi (Graphics, Sound, etc, open-source)
Romans:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
Im not sure if I follow what you mean. Do you want your component to be able to access the properties of a listview on a form, or do you want to create a listview descendant?
Stu