Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-09

TPanel.ComponentCount

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ik

Hello,

I'm trying to do the following code:

for i := 0 to vispan.ComponentCount -1 do
    begin
      if vispan.Components[i] is TSpeedButton then
        begin
          if Assigned(TSpeedButton(vispan.Components[i]).Action) then
            TAction(TSpeedButton(vispan.Components[i]).Action).Enabled := True
          else
            TSpeedButton(vispan.Components[i]).Enabled := True;
        end;
    end;

where vispan is a TPanel that get the current visible panel. However, it seems that ComponentCount is 0, even though it has 7 components inside.
The components does see the TPanel as it's parent, and so does the navigator.

Is it a bug, or am I missing something here ?

Lazarus 1.1 r38512M FPC 2.6.0 x86_64-linux-gtk 2

Thanks,
Ido

Reply by email

patspiper
to ik
ik wrote 23 lines
Hello, I'm trying to do the following code: for i := 0 to vispan.ComponentCount -1 do begin if vispan.Components[i] is TSpeedButton then begin if Assigned(TSpeedButton(vispan.Components[i]).Action) then TAction(TSpeedButton(vispan.Components[i]).Action).Enabled := True else TSpeedButton(vispan.Components[i]).Enabled := True; end; end; where vispan is a TPanel that get the current visible panel. However, it seems that ComponentCount is 0, even though it has 7 components inside. The components does see the TPanel as it's parent, and so does the navigator. Is it a bug, or am I missing something here ? Lazarus 1.1 r38512M FPC 2.6.0 x86_64-linux-gtk 2

Probably the form is the owner and not the panel.

Stephano

Reply by email

ik
to patspiper
patspiper wrote 29 lines
On 04/09/12 22:51, ik wrote: > > Hello, > > I'm trying to do the following code: > > for i := 0 to vispan.ComponentCount -1 do > begin > if vispan.Components[i] is TSpeedButton then > begin > if Assigned(TSpeedButton(vispan.Components[i]).Action) then > TAction(TSpeedButton(vispan.Components[i]).Action).Enabled := > True > else > TSpeedButton(vispan.Components[i]).Enabled := True; > end; > end; > > where vispan is a TPanel that get the current visible panel. > However, it seems that ComponentCount is 0, even though it has 7 > components inside. > The components does see the TPanel as it's parent, and so does the > navigator. > > Is it a bug, or am I missing something here ? > > Lazarus 1.1 r38512M FPC 2.6.0 x86_64-linux-gtk 2 Probably the form is the owner and not the panel.
The panel is the parent. I wrote the following code:
  ShowMessage('btnReloadQuotes.parent: ' + btnReloadQuotes.Parent.Name);

it does claim that the parent is the panel.

Show quoted text 8 lines
Stephano -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Flávio Etrusco
to patspiper: Probably the form is the owner and not the panel. Stephano
patspiper wrote 31 lines
On 04/09/12 22:51, ik wrote: > > Hello, > > I'm trying to do the following code: > > for i := 0 to vispan.ComponentCount -1 do > begin > if vispan.Components[i] is TSpeedButton then > begin > if Assigned(TSpeedButton(vispan.Components[i]).Action) then > TAction(TSpeedButton(vispan.Components[i]).Action).Enabled := > True > else > TSpeedButton(vispan.Components[i]).Enabled := True; > end; > end; > > where vispan is a TPanel that get the current visible panel. > However, it seems that ComponentCount is 0, even though it has 7 > components inside. > The components does see the TPanel as it's parent, and so does the > navigator. > > Is it a bug, or am I missing something here ? > > Lazarus 1.1 r38512M FPC 2.6.0 x86_64-linux-gtk 2 Probably the form is the owner and not the panel. Stephano

Definetely.
What you're missing is that Component* properties refer to owner(ship). You should use ControlCount and Controls properties instead.

-Fl?vio

Reply by email

ik
to Flávio Etrusco
Fl?vio Etrusco wrote 37 lines
On Tue, Sep 4, 2012 at 4:58 PM, patspiper wrote: > On 04/09/12 22:51, ik wrote: >> >> Hello, >> >> I'm trying to do the following code: >> >> for i := 0 to vispan.ComponentCount -1 do >> begin >> if vispan.Components[i] is TSpeedButton then >> begin >> if Assigned(TSpeedButton(vispan.Components[i]).Action) then >> TAction(TSpeedButton(vispan.Components[i]).Action).Enabled := >> True >> else >> TSpeedButton(vispan.Components[i]).Enabled := True; >> end; >> end; >> >> where vispan is a TPanel that get the current visible panel. >> However, it seems that ComponentCount is 0, even though it has 7 >> components inside. >> The components does see the TPanel as it's parent, and so does the >> navigator. >> >> Is it a bug, or am I missing something here ? >> >> Lazarus 1.1 r38512M FPC 2.6.0 x86_64-linux-gtk 2 > > Probably the form is the owner and not the panel. > > Stephano Definetely. What you're missing is that Component* properties refer to owner(ship). You should use ControlCount and Controls properties instead.

Thank you, that works

Show quoted text 8 lines
-Fl?vio -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email