Autor Beitrag
Timbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 166



BeitragVerfasst: Do 19.06.08 11:07 
Hallo, habe ein Frame per IDE erstellt "MyFrame"
ausblenden 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:
unit UMyFrame;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, StdCtrls;

type
  TMyFrame = class(TFrame)
    Button1: TButton;
    Button2: TButton;
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

implementation

{$R *.dfm}

procedure TMyFrame.Button2Click(Sender: TObject);
begin
showmessage('Hallo');
end;

end.


nun möchte ich diese Frame 2 mal in mein Haupt-Form einbauen:
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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses UMyFrame;

var
  Frame1: TMyFrame;
  Frame2: TMyFrame;

procedure TForm1.FormActivate(Sender: TObject);
begin
  Frame1:= TMyFrame.Create(self);
  Frame1.Parent:= self;
  Frame1.Visible:= true;
  Frame1.Top:= 0;
  Frame1.Left:= 0;

  // Beim Starten bekomme ich hier eine Exception "A comppnent MyFrame already exists."
  Frame2:= TMyFrame.Create(self);
  Frame2.Parent:= self;
  Frame2.Visible:= true;
  Frame2.Top:= 200;
  Frame2.Left:= 200;
end;

end.


Was mache ich falsch?

Vielen Dank


Zuletzt bearbeitet von Timbo am Do 19.06.08 13:04, insgesamt 1-mal bearbeitet
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Do 19.06.08 11:24 
Hallo!

Sag ihm mal Frame.Parent:= Form1

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
Timbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 166



BeitragVerfasst: Do 19.06.08 11:41 
immer noch der gleiche fehler:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.FormActivate(Sender: TObject);
begin
  Frame1:= TMyFrame.Create(Form1);
  Frame1.Parent:= Form1;
  Frame1.Visible:= true;
  Frame1.Top:= 0;
  Frame1.Left:= 0;

  // Beim Starten bekomme ich hier eine Exception "A comppnent MyFrame already exists." 
  Frame2:= TMyFrame.Create(Form1);
  Frame2.Parent:= Form1;
  Frame2.Visible:= true;
  Frame2.Top:= 200;
  Frame2.Left:= 200;
end;
Dunkel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 682

Mac OS X Snow Leopard
Xcode 3.1
BeitragVerfasst: Do 19.06.08 11:45 
Versuch mal Deine Frames in OnFormCreate statt im OnFormActivate zu erstellen.

_________________
Ich streite einsam mich mit dieser Oberflächenwelt
Gutes sei ein löblich Brot von dem ich zehre - bis zum Tod [Das Ich - Im Ich]
Timbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 166



BeitragVerfasst: Do 19.06.08 11:52 
hilft auch nicht :(
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Do 19.06.08 11:53 
Mei..ganz klar ;-)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
 Frame1.Name:= 'MeinFrame1';
 //..

 Frame2.Name:= 'MeinFrame2';


Wenn du den ersten Frame erzeugst, bekommt er einen Namen zugewiesen.
Erzeugst du jetzt einen zweiten, bekommt er den selben Namen wie den Ersten und somit existiert die Komponente bereits ;-)

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
Timbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 166



BeitragVerfasst: Do 19.06.08 12:11 
Vielen Dank, machmal ist man aber auch zu blöd, die Fehlermeldung sagt ja eingetlich genau das :P
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Do 19.06.08 12:24 
Markierst du den Thread bitte noch als "Erledigt"?

Danke ;-)
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.