Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Panel.Controls auf TShape prüfen (https://www.delphipraxis.net/112390-panel-controls-auf-tshape-pruefen.html)

Helmi 20. Apr 2008 08:18


Panel.Controls auf TShape prüfen
 
Hallo,

ich steh grad auf dem Schlauch:

Ich lauf mit einer Schleife über alle Controls dir auf einem Panel liegen
und will vergleichen on ein Control ein TShape ist.

Irgendwie hab ich momentan einen Gedankenfehler.

Delphi-Quellcode:
 
for i := 0 to Pred(Panel_MSST.ControlCount) do
    begin
      Dummy_Shape := Panel_MSST.Controls[i] as TShape; //funkioniert nicht
Wie kann ich prüfen ob das Control ein TShape ist.

BTW.: Ich hab schon Panel.Components ausprobiert
aber das funktioniert nicht (ComponentsCount = 0)

toms 20. Apr 2008 08:28

Re: Panel.Controls auf TShape prüfen
 
Delphi-Quellcode:
if Panel_MSST.Controls[i] is TShape then

Helmi 20. Apr 2008 08:33

Re: Panel.Controls auf TShape prüfen
 
Danke! :thumb:

is gibts ja auch noch :-)

toms 20. Apr 2008 09:38

Re: Panel.Controls auf TShape prüfen
 
Zitat:

Zitat von toms
Delphi-Quellcode:
if Panel_MSST.Controls[i] is TShape then

Nachtrag:

Nach der "is"-Überprüfung kannst du anstatt eines Soft Casts einen Hard Cast machen:

Also anstatt:

Delphi-Quellcode:
if Panel_MSST.Controls[i] is TShape then
begin
  Dummy_Shape := Panel_MSST.Controls[i] as TShape;
end
so:

Delphi-Quellcode:
if Panel_MSST.Controls[i] is TShape then
begin
  Dummy_Shape := TShape(Panel_MSST.Controls[i]);
end

Helmi 20. Apr 2008 09:43

Re: Panel.Controls auf TShape prüfen
 
Danke!


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:35 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz