Autor Beitrag
Flash106
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 234


D7 Ent
BeitragVerfasst: Sa 19.03.05 15:53 
Hallo,

ich erstelle in einer MDIAnwendung ein form wenn man auf einen Button klickt und zeige es an. Wenn ich aber nochmal auf den Button klicke wird es nochmal erstellt und angezeigt.. also schon zweimal.. das darf aber nicht passieren.. wie kann das umgehen??

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
//  if form = NIL then <-- das funktioniert nicht 
  form:= Tform.Create(nil);
  form.FormStyle := fsMdiChild;
  form.BorderStyle := bsSizeable;
  form.Show;


hilfe?!
wdbee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 628
Erhaltene Danke: 1



BeitragVerfasst: Sa 19.03.05 16:03 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
...
Form := nil; // Im FormCreate des Hauptformulars z. B.
....

procedure TFormMain.ShowChild;
begin
  if Form = nil then
    Form := CreateChild;
  Form.Show;
end;
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: Sa 19.03.05 16:11 
zeigs mit showmodal an^^
Flash106 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 234


D7 Ent
BeitragVerfasst: Sa 19.03.05 16:28 
danke wdbee!!! Problem gelöst!! :D
wdbee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 628
Erhaltene Danke: 1



BeitragVerfasst: Sa 19.03.05 16:31 
@flash106: Do solltest dir mal ein MDI-Beispielprojekt von Delphi erzeugen, und dann den Code mal anschauen. DATEI-NEU-PROJEKTE: MDI-Anwendung.

Ich denke da findest du einige Anregungen, wie du dein Programm vereinfachen kannst.