Autor Beitrag
motion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 295

XP, Linux
D7 Prof
BeitragVerfasst: Mo 02.05.05 10:11 
ich will eine eigene Ableitung einer Combobox erstellen, welche voreinstellte Properties und eine bereits von mit gefüllte items beinhalten soll.
Funktioniert für auf die Behandlung der Stringlists in den items bzw. itemvalue.
Sobald ich in meiner Ableitung die items anspreche (egal ob per items.clear bzw. items.add('blabla') bekomme einen Fehler, sobald ich versuche die visuelle Komponente auf ein Formalar zu legen (innerhalb der IDE):
Fehler - Element '' hat kein übergeordnetesFenster

Hier der constructor create meiner abgeleiteten Komponenten:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
constructor TMy_DBEingabeMwSt.Create(AOwner: TComponent);
Begin
  inherited;
  style:=csDropdownlist;
  width:=97;
  Showmessage('vor items.clear');
  items.Clear; // <--- dieses hier schlägt fehl!
  itemvalues.clear;
  Showmessage('nach items.clear');
 if  (FindWindow('TApplication', nil) = 0) or
      (FindWindow('TAlignPalette', nil) = 0) or
      (FindWindow('TPropertyInspector', nil) = 0) or
      (FindWindow('TAppBuilder', nil) = 0) then
    Begin {Runtime}
     try
//       showmessage('Runtime');
      items.add('0.) '+FloatToStr(GetMwStSatz(0)));
      items.add('1.) '+FloatToStr(GetMwStSatz(1)));
      items.add('2.) '+FloatToStr(GetMwStSatz(2)));
      items.add('3.) '+FloatToStr(GetMwStSatz(3)));
      items.add('4.) '+FloatToStr(GetMwStSatz(4)));
      itemvalues.add('0');
      itemvalues.add('1');
      itemvalues.add('2');
      itemvalues.add('3');
      itemvalues.add('4');
     except
     End;
    End
  Else
    Begin {design time}
//      showmessage('design time');
      items.add('0.) 0%');
      items.add('1.) 16%');
      items.add('2.) 8%');
      itemvalues.add('0');
      itemvalues.add('1');
      itemvalues.add('2');
    End;

end;

Wie lade ich also die Stringlist der Komponente fehlerfrei in meinem Create constructor?
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 02.05.05 10:17 
Verschiebe mal deine Erzeugungsdinge in AfterConstruction.

Außerdem ein Hinweis: TApplication (deine Anwendung) erzeugt zur Laufzeit IMMER ein Fenster der Klasse "TApplication". Deine Abfrage würde also immer Design-Time liefern.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mo 02.05.05 10:41 
Zur Abfrage ob DesignTime oder RunTime würde ich folgenden Code empfehlen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
if (csDesigning in ComponentState) then
  // .. DesignTime
else
  // RunTime

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
motion Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 295

XP, Linux
D7 Prof
BeitragVerfasst: Mo 02.05.05 14:56 
@BenBE: Habe ich in Afterconstruction verschoben aber leider bleibt das Problem bestehen.

@BenBe, @Motzi: Die DesignTime/RunTime Erkennung habe ich aus der Delphifaq.com kopiert. Ist dort wohl nicht ganz richtig bzw. aktuell.

@Motzi: Dein Codefragment funktioniert wunderbar (Designtime/Runtime Erkennung).