Autor Beitrag
ene
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 779
Erhaltene Danke: 1

Vista, XP, W2K
Delphi, .Net, Deutsch und Englisch
BeitragVerfasst: Do 29.03.07 11:27 
Moin,

ich habe 2 Formulare, von denen ich nur 1 gelegentlich brauche. Da dieses Formular auch nur zum Anzeigen dient und ich meinen Code gern sauber gestalten würde, möchte ich das Formular zu Laufzeit erstellen. Folgende Variante funktioniert:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
Var f: TForm;
Begin
  f:= TForm.Create(Self);
  //...
  f.Visible:= True;
End;


Wie müsste ich es denn machen, wenn ich einen Type deklariert habe, damit ich ein Formular mit diesem Type erzeuge? Oder kann ich mit dem oberen Verfahren auch Mausklicks dort abfangen?

Vielen Dank im Vorraus.
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Do 29.03.07 11:39 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
Var f: TForm;
Begin
  f:= TMyForm.Create(Self);
  //...
  f.Visible:= True;
End;

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
ene Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 779
Erhaltene Danke: 1

Vista, XP, W2K
Delphi, .Net, Deutsch und Englisch
BeitragVerfasst: Do 29.03.07 11:52 
Ressource MyForm nicht gefunden. Der Type MyForm steht in der gleichen Unit unter dem Type des eigentlichen Forms, also im Interface.
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Do 29.03.07 11:54 
ausblenden Delphi-Quelltext
1:
application.createform(TMyform,F);					

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
ene Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 779
Erhaltene Danke: 1

Vista, XP, W2K
Delphi, .Net, Deutsch und Englisch
BeitragVerfasst: Do 29.03.07 11:57 
Gleiche Fehlermeldung :(
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 29.03.07 12:04 
Zeig mal ein bisschen mehr Code, am besten den ganzen interface-Abschnitt der Unit.

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
ene Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 779
Erhaltene Danke: 1

Vista, XP, W2K
Delphi, .Net, Deutsch und Englisch
BeitragVerfasst: Do 29.03.07 12:12 
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:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
Interface

Uses
  Windows, Classes, Dialogs, Menus, GLScene, GLObjects, ExtCtrls,
  GLGeomObjects, ComCtrls, Controls, GLWin32Viewer, Forms, GLMisc,
  GLVectorFileObjects, GLFileSTL,  VectorGeometry, IOStream, GlobalVars,
  Rotate, Divers, Hoehenkarte;
//  f_Planes, Streaming, , BottomTop, , ParseINF, FindMiddleline;

Type
  TUtilities = Class(TForm)
    Sc: TGLScene;
    SV: TGLSceneViewer;
    Kamera: TGLCamera;
    Licht: TGLLightSource;
    Fix: TGLDummyCube;
    BB: TGLDummyCube;
    Menu: TMainMenu;
    Oeffnen: TOpenDialog;
    Speichern: TSaveDialog;
    Datei: TMenuItem;
    LoadIt: TMenuItem;
    SaveIt: TMenuItem;
    QuitIt: TMenuItem;
    Tools: TMenuItem;
    RotiereX0: TMenuItem;
    P1: TGLCone;
    P2: TGLCone;
    P3: TGLCone;
    P4: TGLCone;
    Hoehenkarte: TMenuItem;
    Flaechen: TMenuItem;
    Procedure FormCreate(Sender: TObject);

    Procedure FormKeyPress(Sender: TObject; var Key: Char);
    Procedure SVMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    Procedure SVMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    Procedure FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);

    Procedure LoadItClick(Sender: TObject);
    Procedure SaveItClick(Sender: TObject);
    Procedure QuitItClick(Sender: TObject);

    Procedure HoehenkarteClick(Sender: TObject);
    Procedure RotiereX0Click(Sender: TObject);
    Procedure FlaechenClick(Sender: TObject);

  Private  MyX, MyY      : Integer;
End;

Type
  TMyForm = Class(TForm)
    FGS: TGLScene;
    FSV: TGLSceneViewer;
    FKamera: TGLCamera;
    FFix: TGLDummyCube;
    FTop: TGLFreeForm;
    FBot: TGLFreeForm;
    FLicht: TGLLightSource;
End;

Var
  Utilities: TUtilities;


Und hier der Aufruf:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
Var
  F: TForm;
Begin
  Application.CreateForm(TMyForm, F);
  F.Visible:= True;
End;
Steve1024
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 141

Windows 2K, XP, 7 & Server 2003 - 2008; Linux (Ubuntu, Fedora)
D7, D05, D06, D09, DXE
BeitragVerfasst: Do 29.03.07 12:36 
Delphi lädt Forumale mithilfe von Resourcen. Da steht dann drin, wo welche Komponente ist.
Da du die TMyForm nicht über Delphi erzeugt hast, fehl auf die *.dfm dazu. Somit gibt es keine Resource dazu.

Erstell die TMyForm mithilfe von Delphi (als ganz normales Formular) und hast eine .dfm Datei. Also auch eine Resource.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 29.03.07 13:08 
Genau.. wenn du allerdings keine Resource benötigst geht es auch ohne, dazu muss man den Constructor ein bisschen umschreiben - wie das geht hab ich schonmal in diesem Thread gezeigt: www.delphi-forum.de/viewtopic.php?t=61854

Gruß, Motzi

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
ene Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 779
Erhaltene Danke: 1

Vista, XP, W2K
Delphi, .Net, Deutsch und Englisch
BeitragVerfasst: Do 29.03.07 13:35 
Ok, ich denke ich weiß, was ihr meint. Da aber leider morgen Abgabe ist, werde ich mir das aufs ToDo für V1.1 schreiben. Vielen Dank trotzdem!