Autor Beitrag
mcst09
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Fr 02.06.06 08:03 
Hallo,

gibt es eine Möglichkeit, die Namen der Formulare meiner Anwendung abzufragen und in eine ComboBox zu laden?
Dies alles soll natürlich zur Laufzeit erfolgen...just for Info!

Axl
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Fr 02.06.06 08:13 
Form.Name;
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Fr 02.06.06 08:16 
Hallo,

schau Dir mal Screen.FormCount und Screen.Forms[x] an.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
azubi_20
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 593

WinXP SP2, Ubuntu 8.4
D7 Enterp., D2005 Prof., Java (Eclipse 3.4.0)
BeitragVerfasst: Fr 02.06.06 08:36 
Die obrigen Beiträge ergeben folgende Funktion :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure LoadNameOfFormsInCombobox(cb : TComboBox; SendForm : TForm);
var i: Byte;
begin
  // Einträge in Combobox löschen
  cb.Clear;
  // Alle Forms durchgehen
  for i := 0 to Screen.FormCount - 1 do
  begin
    // Eintrag hinzufügen
    cb.AddItem(Screen.Forms[i].name, SendForm);
  end;
  // ersten Eintrag anzeigen
  cb.ItemIndex := 0;
end;


Beispielaufruf :
ausblenden Delphi-Quelltext
1:
LoadNameOfFormsInCombobox(combobox1,self);					
mcst09 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Sa 03.06.06 00:20 
hallo,

kann man so auch formulare auslesen die zu dem zeitpunkt nicht geladen sind, aber die in der anwendung existieren??

axl
FrankLink
Hält's aus hier
Beiträge: 8

Win XP, Win 2003, LINUX
Delphi 2005 Arch.; JAVA, C#,...
BeitragVerfasst: Sa 03.06.06 18:02 
Hallo,
das funktioniert nur, wenn du alle Formulare auf automatisches Erstellen stehen hat. Das bedeutet, dass Du alle Formulare beim Start Deine Anwendung automatisch durch Delphi-Code erzeugen läst.

Machst Du das nicht, so kennt Deine Anwendung die Formularklassen nicht.

Ich habe das in meiner Anwendung so geregelt, dass ich alle meine Formulare generell in einem Array verwalte. Dann kann ich die einzelnen Formularklassen über das Array abfragen.

Es gibt auch nach andere Lösungen mit RegisterClass und dann über alle registrierten Klassen interieren und prüfen ob Sie von TForm oder einer BasisKlasse von der Du Deine Formulare ableitest abgeleitet sind.

Aber der einfachste Weg ist alle Deine Formulare in einem Array zu speichern, dass Du global verfügbar machst. Dann kannst Du Deine Kombobox aus dem Array befüllen.

Gruss
Frank

_________________
Ein fehlerfreies Programm ist ein Novum
mcst09 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Sa 03.06.06 20:02 
Hallo Frank,

danke für die Ratschläge.
Kannst Du mir noch verraten wie das Array aufgebaut ist?
Was genau steht dort drin?

Danke
Axl
Softchaos67
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 103

XP Prof
Delphi 7
BeitragVerfasst: Do 03.08.06 11:02 
user profile iconFrankLink hat folgendes geschrieben:
Hallo,
Es gibt auch nach andere Lösungen mit RegisterClass und dann über alle registrierten Klassen interieren und prüfen ob Sie von TForm oder einer BasisKlasse von der Du Deine Formulare ableitest abgeleitet sind.
Frank


Wie macht man das genau?
Das würde mich sehr Interressieren.
Gruss
Matthias

_________________
cum grano salis