![]() |
Find Component
Zu welcher Unit gehört eigentlich FindComponent? Ich hab bei meiner eigenen Unit folgende uses-Zeile:
Delphi-Quellcode:
und erhalte beim Befehl 'FindComponent' immer die Meldung 'undeclared identifier';
uses SysUtils, ExtCtrls, StdCtrls, Controls, Classes, Graphics, Dialogs;
|
FindComponent ist keine Funktion oder Prozedur, sondern eine Method von TComponent. Diese wiederum befindet sich in Classes.pas.
|
Aber warum spuckt er mir dann bei obriger Deklaration diese Meldung aus - denn Classes hab ich ja aufgeführt....
|
An welcher Stelle benutzt Du die Methode denn. Wahrscheinlich in einer Prozedur/Funktion ausserhalb einer Klasse, bzw. in einer Methode einer Klasse, welche nicht von TComponent abgeleitet wurde.
...:cat:... |
Ich poste hier mal die Unit:
Delphi-Quellcode:
unit UnitFunc;
interface uses SysUtils, ExtCtrls, StdCtrls, Controls, Classes, Graphics, Dialogs; {Standard-Units auf die zurückgegriffen wird} procedure Farbewechseln (Sender: TPanel; Button: TMousebutton); function Zeitangabe:string; function THL (Sender: TImage; Button: TMousebutton; Bild: boolean): boolean; function Sound (Sender: TImage; Button: TMousebutton; Bild: boolean): boolean; function Schloss (Sender: TImage; Button: TMousebutton; Bild: boolean): boolean; procedure speichern; implementation procedure speichern; var save: Textfile; Hname, Zeit, HFarbe, kette: string; Schl, THL, Sound:boolean; i: integer; begin kette := ''; for i := 1 to 35 do begin kette := kette + ((FindComponent('PanLab' + IntToStr(i)) as TLabel) .Caption, (FindComponent('PanLabT' + Inttostr(i)) as TLabel).caption, IntToHex(((FindComponent('PanHalle' + InttoStr(i))as TPanel).Color),6), BoolToStr(bildTHL[i]), BoolToStr(bildSchl[i]),BoolToStr(bildSound[i])); end; end; |
FindComponent ist eine Methode von TComponent. Du kannst sie nur innerhalb einer Klasse bzw. Mit "IrgendeinObjekt.FindComponent" aufrufen.
Da ich annehme das die gesuchte Komponente auf dem Hauptformular liegt, kannst du mit Application.MainForm.FindComponent auf dieses zugreifen. |
du kannst auch der speichern prozedur als parameter das formular angeben! (alternative)
Delphi-Quellcode:
natürlich gehts auch mit Application.MainForm.FindComponent
unit UnitFunc;
interface uses SysUtils, ExtCtrls, StdCtrls, Controls, Classes, Graphics, Dialogs; {Standard-Units auf die zurückgegriffen wird} procedure Farbewechseln (Sender: TPanel; Button: TMousebutton); function Zeitangabe:string; function THL (Sender: TImage; Button: TMousebutton; Bild: boolean): boolean; function Sound (Sender: TImage; Button: TMousebutton; Bild: boolean): boolean; function Schloss (Sender: TImage; Button: TMousebutton; Bild: boolean): boolean; procedure speichern(formular: TForm); implementation procedure speichern(formular: Tform); var save: Textfile; Hname, Zeit, HFarbe, kette: string; Schl, THL, Sound:boolean; i: integer; begin kette := ''; for i := 1 to 35 do begin kette := kette + ((Formular.FindComponent('PanLab' + IntToStr(i)) as TLabel) .Caption, (Formular.FindComponent('PanLabT' + Inttostr(i)) as TLabel).caption, IntToHex(((Formular.FindComponent('PanHalle' + InttoStr(i))as TPanel).Color),6), BoolToStr(bildTHL[i]), BoolToStr(bildSchl[i]),BoolToStr(bildSound[i])); end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:58 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz