Autor Beitrag
rolX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25


D5
BeitragVerfasst: Fr 07.01.05 11:49 
Hallo zusammen,

bin Einsteiger :( und kämpfe mit entsprechenden (ungewohnten) Eigenschaften von Delphi. Wieso bekomme ich eine Fehlermeldung beim Aufruf der Funktion 'FindComponent' in einer Unit, die bereits Funktionen enthält, in welchen 'FindComponent' fehlerfrei aufgerufen werden kann?

Etwas Quellcode zur Veranschulichung:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
function boGetCheckboxValue(iMainKat: Integer; iSubKat: Integer): boolean;
var szMainKat    : String;
    szSubKat     : String;
    szControlName: String;
    boReturn     : boolean;
begin

Im ersten Teil wird der Name der Checkbox anhand der Kategorien ermittelt...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
    if iSubKat = 0 then
      begin
        szControlName := 'chkKat';
        szControlName := szControlName + '0' + IntToStr(iMainKat);
      end
    else
      begin
        szControlName := 'chkUKat';
        szControlName := szControlName + '0' + IntToStr(iMainKat) + '0' + IntToStr(iSubKat);
      end;

Hier wird nun abgefragt, ob ein Häkchen oder net...
Hier schimpft er mit mir... Warum??
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
    with TCheckBox(FindComponent(szControlName)) do
    begin
        if Checked then
          boReturn := true
        else
          boReturn := false;
    end;

  // Ergebnis...
  result := boReturn;
end;


Danke im Voraus für die Hilfe.

rolX

--
Die Zehn Gebote Gottes sind deshalb so eindeutig weil sie nicht erst auf einer Konferenz beschlossen wurden.

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 07.01.05 11:52 
Titel: Re: Wieso 'undeclared Identifier' bei aufruf von FindCompone
rolX hat folgendes geschrieben:
Wieso bekomme ich eine Fehlermeldung beim Aufruf der Funktion 'FindComponent'

Rat mal, wa du vergessen hast uns mitzuteilen. :roll:
matze.de
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: Fr 07.01.05 11:57 
komm lass nen ratespiel machen... ich denke mir eine Fehlermeldung mit der Codenummer und du musst raten. also sag mir eine zahl zwischen 0 und 16000 :]

mfg matze

_________________
si tacuisses, philosophus mansisses.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 07.01.05 11:58 
Ich vermute mal, dass das eine selbst geschriebene Prozedur ist, die nicht zur Form-Komponente gehört.
Dann kennt Delphi natürlich nicht FindComponent, da es eine Funktion von (z.B.) TForm ist.
Deklariere deine Prozedur in public-Bereich der Form und schreibe den Komponentennamen (TForm1.) vor deine Prozedur.
Dann sollte es theoretisch klappen, falls ich richtig geraten habe.
rolX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25


D5
BeitragVerfasst: Fr 07.01.05 12:16 
Titel: Die Nummer...
Hallo,

sorry, die Nummer ist 200


@ jasocul
mit der folgenden Deklaration tut's leider auch net:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
  public
    { Public declarations }
    function TfrmKategorieWahl.boGetCheckboxValue(iMainKat: Integer; iSubKat: Integer): boolean;
  end;



rolX

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
IngoD7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 629


D7
BeitragVerfasst: Fr 07.01.05 12:16 
jasocul hat folgendes geschrieben:
... und schreibe den Komponentennamen (TForm1.) vor deine Prozedur.

(Erbsenzähler ON)
Das ist der Komponententyp. :)
(Erbsenzähler OFF)

Den Namen (also z.B. Form1) kannst du auch einfach vor das FindComponent schreiben - also with TCheckBox(Form1.FindComponent(szControlName)) do

Dann sollte es auch schon funktionieren.
matze.de
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: Fr 07.01.05 12:19 
Titel: Re: Die Nummer...
rolX hat folgendes geschrieben:

sorry, die Nummer ist 200


das glaub ich windoof aber nicht :)

Zitat:

200 The code segment cannot be greater than or equal to 64K. ERROR_RING2SEG_MUST_BE_MOVABLE


oder versteh ich den windows errror falsch? :?:

mfg matze

_________________
si tacuisses, philosophus mansisses.
rolX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25


D5
BeitragVerfasst: Fr 07.01.05 12:21 
Leider nicht,

der Aufruf:
ausblenden Quelltext
1:
with TCheckBox(TfrmKategorieWahl.FindComponent(szControlName)) do					


erzeugt den Fehler Nr. 202: This form of method call only allowed for class methods

rolX
rolX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25


D5
BeitragVerfasst: Fr 07.01.05 12:27 
@IngoD7

Hallo,

mein Fehler... es tut nun, wenn ich das "T" weg lasse - also:

ausblenden Quelltext
1:
with TCheckBox(frmKategorieWahl.FindComponent(szControlName)) do					



Ich seh' schon, ich hab' noch viel zu lernen... aber vielen Dank mal für's Erste.

rolX


--
Auch im Osten traegt man Westen.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 07.01.05 12:50 
Das ist dann aber nicht mehr so schön Objekt-Orientiert programmiert. :cry:

@IngoD7:
Alle Erbsenzähler raus hier :!:
Hast natürlich recht.
IngoD7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 629


D7
BeitragVerfasst: Fr 07.01.05 12:56 
rolX hat folgendes geschrieben:
@IngoD7
es tut nun, wenn ich das "T" weg lasse


Ich wollte dir auch gerade einen erzählen .... :lol:

Das hatte ich nämlich auch so geschrieben (ohne T). 8)
IngoD7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 629


D7
BeitragVerfasst: Fr 07.01.05 13:03 
jasocul hat folgendes geschrieben:
Das ist dann aber nicht mehr so schön Objekt-Orientiert programmiert. :cry:

Da hast du nicht unwahr.
Kannst ja deinen Vorschlag nochmal durchsetzen. :wink:
rolX hatte ihn ja versucht, zu verfolgen, allerdings bei der Deklaration der Procedure fälschlicherweise auch den Typ davor gesetzt (sein Posting von heute, 12:16h).
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 07.01.05 13:20 
Versuchen wir es mal:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
TFormKategorieWahl = class(TForm)
...
public
  function boGetCheckboxValue(iMainKat: Integer; iSubKat: Integer): boolean;
..
end;
...

function TFormKategorieWahl.boGetCheckboxValue(iMainKat: Integer; iSubKat: Integer): boolean;
begin
  //Dein Source mit FindComponent
end;
rolX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25


D5
BeitragVerfasst: Fr 07.01.05 13:33 
Ihr seid spitze!

auch das tut. Da ich aus der VB-Ecke komme und gerne auf Delphi umsteigen möchte tue ich mich mit dem Konzept etwas schwer. In VB kann man von Modul (=Unit) zu Modul oder von Formular zu Formular springen, wie's gerade bekommt. Delphi ust da net so tolerant und das macht mir gerade noch zu schaffen.

Also - vielen Dank für Eure sehr schnelle und professionelle Hilfe!

rolX


--
die drei Todfeinde des Programmierers:
- Sonnenlicht
- Frische Luft
- das ohenbeteubende geschrei der Vögel