Wein
asked on
_ Getting the total number of a component.
Suppose in a running app, I created some visual component.
(e.g. TCOMP)
how can i know how much TCOMP i have and have access to each of them?
Wein.
(e.g. TCOMP)
how can i know how much TCOMP i have and have access to each of them?
Wein.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Example...
var
i : integer;
begin
for i := 0 to ComponentCount - 1 do
if Components[i] is TComp then
ShowMessage(TComp(Componen ts[i]).Nam e);
end;
Cheers,
Viktor
var
i : integer;
begin
for i := 0 to ComponentCount - 1 do
if Components[i] is TComp then
ShowMessage(TComp(Componen
end;
Cheers,
Viktor
ASKER
How can we add things to a component array?
I need some source code
I need some source code
CompArray= array [0...MAX] of TCOMP;
counter:=0;
.
When you need to create:
CompArray[Counter]:=TCOMP. Create(... );
Counter:=Counter+1;
..
When you need to access:
CompArray[i].Method/proper ty .....
counter:=0;
.
When you need to create:
CompArray[Counter]:=TCOMP.
Counter:=Counter+1;
..
When you need to access:
CompArray[i].Method/proper
var
TCompo : array [0..5] of TComp;
i : Integer;
{...}
for i := 0 to 5 do begin
TCompo[i] := TComp.Create;
TCompo[i].Width := 50;
{...}
end;
OnDestroy()
for i := 0 to 5 do
TCompo[i].Free;
Cheers,
Viktor
TCompo : array [0..5] of TComp;
i : Integer;
{...}
for i := 0 to 5 do begin
TCompo[i] := TComp.Create;
TCompo[i].Width := 50;
{...}
end;
OnDestroy()
for i := 0 to 5 do
TCompo[i].Free;
Cheers,
Viktor
ASKER
Should I give the points to dwwang or viktornet ?
He provided a clearer source. But I received the same idea from dwwang first.
I don't want to have a bad impression to any of you. So decide who wants the points. And I can also increase or decrese the points.
Wein.
He provided a clearer source. But I received the same idea from dwwang first.
I don't want to have a bad impression to any of you. So decide who wants the points. And I can also increase or decrese the points.
Wein.
it doesn't make any difference to me :)
Take it easy, we won't have any bad impression for you. To answer the question is our pleasure, and score is just for interesting.
The only thing I need to see is Delphi spreading all over the world and for-ever!
The only thing I need to see is Delphi spreading all over the world and for-ever!
:)
Form1.ComponentCount