Autor Beitrag
der_zaehe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: So 06.02.05 10:37 
Moin!

Da ich momentan an einem chat arbeite, der auch wirklich brauchbar sein soll, hatte ich die idee, auch einen "privat" - Modus einzuführen, bei dem immer nur 2 Leute miteinander chaten. Ich hatte mir das so vorgestellt, das dafür immer ein neues Fenster geöffnet wird (wie bei icq), in dem man sich privat unterhält. Leider hab ich keine Ahnung, wie sowas geht. (Wie kann ich beliebig viele Fenster der selben Sorte öffnen, wie die die Server- und die Client-Komponente im Hauptform nutzen usw.) Ich foffe auf eure guten Tips :)
danke schon mal im voraus.

_________________
[inspirationslos]
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 06.02.05 10:39 
Schau dir mal MDI bzw. SDI Anwendungen an. Da ist in jedem Delphi ein Beispiel-Projekt dabei.

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
matze.de
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: So 06.02.05 10:44 
Hey,
das geht mit Pointern wunderbar, schau dir umbedingt mal das Pointer Tutorial hier im forum an, das beinhaltet sogar ein programm mit dem man mehrere fenster öffnen und schließen kann.
Pointer Tut

mfg matze

_________________
si tacuisses, philosophus mansisses.
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: So 06.02.05 11:46 
Hi,

das Pointer tut ist ja ganz schön, ist es hier aber nicht etwas oversized?
Edit: Habe gerade gesehen, daß du eh ne liste verwendest. Also finde ich nur das mit den pointern etwas komisch.[/edit]

Beim schließen des Fensters kann er einfach mittels List.Index(SeinForm) die referenz löschen und gut ist....

Also in etwa so im MainForm
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:
...
  private
    FWindowList: TList;
  public
    procedure DeleteChildWindow(AChild: TForm); 
...

// im OnCreate des Hauptfensters ein
// FWindowList := TList.Create;

//hier der button zum öffnen eines Fensters
procedure TFormMain.OnPrivateClick(Sender: TObject);
var
  LPrivateForm: TDeinePrivateForm
begin
  LPrivateForm := TDeinePrivateForm.create(nil)
  FWindowList.add(LPrivateForm);
  LPrivateForm.show;
end;

procedure TFormMain.DeleteChildWindow(AChild: TForm);
begin
  FWindowList.delete(FWindowList.IndexOf(AChild));
end;

Dazu muss das PrivateForm ein uses auf das MainForm im implementation teil machen und dann kann man im OnClose des PrivateForms folgendes machen, damit die Referenz auch wieder wech ist...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure PrivateForm.OnClose(Sender: TObject);
begin
  MainForm.deleteChildWindow(Self);
end;


Gruß
Ken

_________________
Eine Klasse beschreibt die Struktur und das Verhalten einer Menge gleichartiger Objekte.
matze.de
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: So 06.02.05 12:00 
CenBells hat folgendes geschrieben:

...das Pointer tut ist ja ganz schön, ist es hier aber nicht etwas oversized?


Wie soll ich das verstehen? o0


mfg matze

_________________
si tacuisses, philosophus mansisses.
der_zaehe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: So 06.02.05 12:06 
danke matze!
das tutorial ist ziemlich genau das was ich gesucht hab :D . Ich habs jetzt mal überflogen, ich schreib noch mal hier rein falls ich noch irgendwelche fragen hab.

_________________
[inspirationslos]
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: So 06.02.05 12:09 
CenBells hat folgendes geschrieben:
das Pointer tut ist ja ganz schön, ist es hier aber nicht etwas oversized?

Doch ist es eigentlich schon... da Objekte ja eigentlich bereits Pointer sind ist es eigentlich komplett unnötig diese nochmal über einen eigenen Pointer zu referenzieren, da man dadurch eigentlich nur mit Pointern auf Pointer arbeitet. Stattdessen kann man auch direkt die Objekt-Pointer zur Liste hinzufügen.

Das Tutorial ist schon uralt (ich hab das vor ungefähr 4 Jahren oder mehr geschrieben) und ich hatte damals kein besseres Beispiel zur Hand. Ich bin aber zur Zeit gerade dabei das Tutorial von Grund auf komplett zu überarbeiten und auch viele neue Sachen einzubringen.

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

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: So 06.02.05 12:19 
hi cenbells!
hab gerade eben erst deine antwort gekriegt, ich hatte die seite nicht aktualisert, bevor ich gepostet hab. :roll:
ich kann da nur zustimmnen, das für mein problem die pointervariante oversized ist. Ich habs jetzt mal mit deinem verfahren probiert und bist jetzt gings wunderbar :)

_________________
[inspirationslos]
matze.de
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: So 06.02.05 12:21 
ich wusste nicht, dass es intern schon mit poitern gehandelt wird, und da ich gestern das tut mal gelesen hatte, hatt ichs noch im kopf :D

mfg matze

_________________
si tacuisses, philosophus mansisses.
der_zaehe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: So 06.02.05 12:40 
so, grade tut sich bei mir das nächste problem auf:
ich hab in die unit von meinem "mainform" die unit meines "multipleform" eingebunden, das er den objekttyp TForm2 kennt.
Das dieses Form 2, mein "multipleform". dann noch zugriff auf form1 hat, wollte ich die unit des "mainform" in die unit des "multipleform" einbinden. Dann aber motzt der gleich rum und meint:
[Fatal Error]Form1_unit.pas(7): Circular unit reference to 'Form2_unit' :?:
Ich kann mir vorstellen, warum er dann motzt, aber ich weiß nicht, wie ichs anders machen soll :gruebel:

_________________
[inspirationslos]
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: So 06.02.05 15:18 
hi,

im main form packst du die referenz auf das multiple form in das uses im interface teil der unit.
In der Unit für das Multiple form packst du das Main form in eine uses klauses im implementation teil.

Hatte ich oben auch angedeutet.
Zitat:
Dazu muss das PrivateForm ein uses auf das MainForm im implementation teil machen und dann kann man im OnClose des PrivateForms folgendes machen, damit die Referenz auch wieder wech ist...


Gruß
Ken

_________________
Eine Klasse beschreibt die Struktur und das Verhalten einer Menge gleichartiger Objekte.
der_zaehe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: So 06.02.05 19:05 
Sry, habs überlesen. Bei mir geht jetzt alles, danke an alle für die schnelle Hilfe!
:)

_________________
[inspirationslos]
der_zaehe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: So 06.02.05 19:26 
mist, gibt immer noch nen prob: bei
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  MainForm.deleteChildWindow(Self);
end;

murrt er rum, MainForm wäre kein gültiger Bezeichner. In der Annahme, das das der Name des Hauptformulars und kein feststehender Bezeichner ist, hab ich einfach mal Form1 genommen, das jedoch hatte kein deleteChildWindow
Was mach ich nur falsch :?:

_________________
[inspirationslos]
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 06.02.05 20:16 
man kann das form1 auch weglassen dann bezieht sich das immer auf das übergeordnete Objekt also das parentwindow, in diesem fall das main formular
der_zaehe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: So 06.02.05 21:00 
F34r0fTh3D4rk hat folgendes geschrieben:
man kann das form1 auch weglassen dann bezieht sich das immer auf das übergeordnete Objekt also das parentwindow, in diesem fall das main formular


Ich hab nicht ganz verstanden, auf was du dich da beziehst:
bezieht sich das auf DeleteChildWindow? wenn ja, dann gings net. wenn nein würde ich dich bitten, mir zu verraten, wo man denn das form1 weglassen kann, und was sich dann immer auf das übergeordnete Objekt bezieht. :)

_________________
[inspirationslos]
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 06.02.05 21:21 
da :gruebel:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);  
begin  
  deleteChildWindow(Self);  
end;
der_zaehe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: So 06.02.05 21:32 
komisch...
genau da hab ichs reingehauen und er meint " Undeclared identifier: 'deleteChildWindow' "

_________________
[inspirationslos]
der_zaehe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: So 06.02.05 22:06 
ah, es geht net, weil ich die procedure net deklariert hab :roll:
und wie kann ich jetzt auf mein form1 zugreifen? wenn ich form1.bla.. schreib, krieg ich nur AccesViolation

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

interface

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

type
  TForm2 = class(TForm)
    StaticTextZeit: TStaticText;
    StaticTextDatum: TStaticText;
    MemoAusgabe: TMemo;
    MemoEingabe: TMemo;
    StaticTextZeichen: TStaticText;
    StaticTextZeichenZahl: TStaticText;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

uses Zchat_unit;

var Form1: TForm1;



{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
begin
  MemoAusgabe.Clear;
  MemoEingabe.Clear;
  StaticTextZeit.Caption := TimeToStr(Time);
  StaticTextDatum.Caption := DateToStr(Date);
end;

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  //Form1.irgendwas <= hier krieg ich den AccesViolation
end;

end.


ich hab mein problem jetzt selbst gelöst und schreib das hier per edit, weil ich das ohnehin schon gelöste problem net noch mal nach vorne schieben will :)

_________________
[inspirationslos]