AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Problem mit 2. Formular

Ein Thema von gfjs · begonnen am 23. Jan 2006 · letzter Beitrag vom 25. Jan 2006
Antwort Antwort
Elvis

Registriert seit: 25. Nov 2005
Ort: München
1.909 Beiträge
 
Delphi 2010 Professional
 
#1

Re: Problem mit 2. Formular

  Alt 25. Jan 2006, 22:33
Du willst also die globale Variable des d32 Designers simulieren?
Der Trick wäre eine class property, die beim Zugriff eine Instanz anlegt und dieser AllowDisposing false über gibt.
Delphi-Quellcode:
class property Instance : Form1 read get_Instance;
property AllowDisposing : Boolean := true;
Delphi-Quellcode:
class function Form1.get_Instance: Form1;
begin
   if not assigned(fInstance) then
   begin
      fInstance := new Form1();
      fInstance.AllowDisposing := false;
   end;
   
   result := fInstance;
end;
Im FormClosing event noch das hier:
Delphi-Quellcode:
procedure Form1.Form1_FormClosing(sender: Object; e: FormClosingEventArgs);
begin
   if not AllowDisposing then
   begin
      e.Cancel := true;
      Hide();
   end;
end;
Damit ein Disosed fInstance auch wieder neu angelegt wird, müsste Dipose angepasst werden:
Delphi-Quellcode:
method Form1.Dispose(disposing: boolean);
begin
   if disposing then
   begin
      if assigned(components) then
         components.Dispose();
      if self = fInstance then
         fInstance := nil;
   end;
   inherited Dispose(disposing);
end;
Im HauptForm sowas:Form1.Instance.Show();
Das hätte auch den Vorteil, dass man weiter hin neue Instanzen von Form1 anlegen könnte, die sich beim Close zertören.

Edit, bin etwas handicapped, da ich eine andere Tastatur benutze... (Zu oft Alt + S statt Alt + D getippt )
Robert Giesecke
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:27 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz