Autor Beitrag
Wolle92
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Do 26.06.08 18:52 
Hallo,

ich hab nen Problem mit meinen Klassen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
type TSelForm = class(TForm)
  CaptionLabel: TLabel;
end;

...

self.SelForm := TSelForm.Create(AOwner);


Der Compiler sagt nix, alles OK...
Aber zur Laufzeit kriege ich dann ein EResNotFound mit der Meldung "Ressource TSelForm wurde nicht gefunden"...

Woran liegt das?
Der untere Befehl steht in einem Constructor einer anderen Klasse, die aber in der gleichen Datei deklariert ist, der AOwner wird dem Constructor übergeben...


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Do 26.06.2008 um 19:54

_________________
1405006117752879898543142606244511569936384000000000.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 26.06.08 18:58 
Moin!

Schau dir mal in der DOH die Methode TForm.CreateNew() an. Ausserdem ist der Eigentümer von Formularen immer das TApplication-Objekt. :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Do 26.06.08 19:01 
hm... kann der owner nicht auch eine andere Form sein? Sozusagen nen Frame, nur als Form...

Compilertechnisch geht das nämlich...

_________________
1405006117752879898543142606244511569936384000000000.
j.klugmann
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 26.06.08 19:35 
hääh... ein frame als form ?
wie meinst du das? :?: :?: :?: :?: :?:
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Do 26.06.08 20:01 
wenn die form ne andere form als owner hat, dann iostz es ja wie bei einem frame... nur ist es eben ne Form, vom typ her...

_________________
1405006117752879898543142606244511569936384000000000.
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Do 26.06.08 21:15 
Ja das geht, wird IIRC u.a. bei der Demo vom VirtualStringTree so gemacht.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Do 26.06.08 22:11 
Poste mal bitte die gesamte .pas Datei, ich hab da so ne Vermutung.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Do 26.06.08 22:13 
Wenn du eine Form mit Create erstellst, musst du die entsprechenden Formdaten als Ressource eingebunden haben: {$R *.dfm}
Wenn du eine Form mit CreateNew erstellst sind keine Komponenten auf der Form instanziert, brauchst dafür auch keine Formdaten.

user profile iconNarses hat folgendes geschrieben:
Ausserdem ist der Eigentümer von Formularen immer das TApplication-Objekt
Der Owner kümmert sich nur um die Freigabe und kann theoretisch eine beliebige TComponent Instanz sein. Wenn du dich um die Freigabe selbst kümmerst musst du keinen Owner angeben. Forms, die über Application.CreateForm erstellt werden haben automatisch Application als Owner.
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Fr 27.06.08 06:43 
So, ganzer Code:

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:
unit DirSelect;

interface

uses
  Windows, SysUtils, Forms, Classes, Controls, StdCtrls, ExtCtrls;

type TSelForm = class(TForm)
  CaptionLabel: TLabel;
end;

type TDirSelect = class
  private
    Form: TSelForm;
    dir: String;
  public
    constructor Create(AOwner: TComponent);
end;

implementation

constructor TDirSelect.Create(AOwner: TComponent);
begin
  inherited Create;
  self.Form := TSelForm.CreateNew(AOwner);
  self.Form.ClientWidth := 300;
  self.Form.ClientHeight := 500;
  self.Form.Position := poScreenCenter;
  self.Form.Caption := 'Ordner-Auswahl';
  self.Form.CaptionLabel.Caption := 'Wählen sie einen Ordner aus:';
  self.Form.Show;
end;

end.


Also die Form wird mittlerweile auch angezeigt...
Aber das Label darauf nicht, auch nicht, wenn ich Höhe, Breite, Top und Left angeben und sogar noch Show aufrufe...

_________________
1405006117752879898543142606244511569936384000000000.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Fr 27.06.08 22:17 
user profile iconWolle92 hat folgendes geschrieben:
Also die Form wird mittlerweile auch angezeigt...
Aber das Label darauf nicht

user profile icondelfiphan hat folgendes geschrieben:
Wenn du eine Form mit Create erstellst, musst du die entsprechenden Formdaten als Ressource eingebunden haben: {$R *.dfm}
Wenn du eine Form mit CreateNew erstellst sind keine Komponenten auf der Form instanziert, brauchst dafür auch keine Formdaten (... dafür musst du die Komponenten selbst instanzieren und initialisieren).
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Sa 28.06.08 16:00 
hatte ich auch gemacht, aber das Parent hat gefehlt...

_________________
1405006117752879898543142606244511569936384000000000.
SvenAbeln
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 334
Erhaltene Danke: 3



BeitragVerfasst: Sa 28.06.08 18:11 
Die DFM-Datei von deinem Formular wird nicht in die EXE gelinkt.

Versuch es mal mit dieser Änderung:

ausblenden Delphi-Quelltext
1:
2:
3:
implementation

{$R *.dfm}
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: So 29.06.08 10:24 
ich hab ja keine dfm... das Formular wird nur aus text erstellt...

_________________
1405006117752879898543142606244511569936384000000000.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: So 29.06.08 11:15 
Wieso kreierst du nicht eine Form via Design-Editor?
SvenAbeln
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 334
Erhaltene Danke: 3



BeitragVerfasst: So 29.06.08 11:27 
user profile iconWolle92 hat folgendes geschrieben:
ich hab ja keine dfm... das Formular wird nur aus text erstellt...


user profile iconWolle92 hat folgendes geschrieben:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
type TSelForm = class(TForm)
  CaptionLabel: TLabel;
end;

...

self.SelForm := TSelForm.Create(AOwner);



Dann ist es auch kein Wunder, dass dort kein Label angezeigt wird, es wird ja überhaupt kein Label erzeugt.

Wenn du das Form schon komplett im Quelltext erzeugen möchtest, dann musst du auch
alle dort enthaltenen Komponenten selbst erzeugen und richtig anordnen.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
  CaptionLabel:= TLabel.Create(self);
  CaptionLabel.Parent:=...
  CaptionLabel.Left:=...
usw.


Aber viel einfacher geht es über den Formular Editor und einem DFM.
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: So 29.06.08 13:07 
jetzt funktioniert ja alles ;)

_________________
1405006117752879898543142606244511569936384000000000.