AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Abfrage ob GUI Control noch vorhanden ist.

Abfrage ob GUI Control noch vorhanden ist.

Ein Thema von stalkingwolf · begonnen am 24. Mai 2017 · letzter Beitrag vom 24. Mai 2017
Antwort Antwort
Benutzerbild von Jasocul
Jasocul

Registriert seit: 22. Sep 2004
Ort: Delmenhorst
1.374 Beiträge
 
Delphi 11 Alexandria
 
#1

AW: Abfrage ob GUI Control noch vorhanden ist.

  Alt 24. Mai 2017, 14:29
Wenn ich das richtig sehe, ist das eine Routine im DataModul und das wird einem Event in "Screen" zugewiesen.

Man könnte natürlich mit einem Try..Except arbeiten, was meiner Meinung nach zwar der einfachste, aber "unschöne" Weg ist.
Ich würde aus dieser Routine eine Komponente machen und auf der jeweiligen Form platzieren. Alternativ wäre noch die Variante über einen ClassHelper für TForm denkbar.
Peter
  Mit Zitat antworten Zitat
SneakyBagels
(Gast)

n/a Beiträge
 
#2

AW: Abfrage ob GUI Control noch vorhanden ist.

  Alt 24. Mai 2017, 14:34
Nur lößt das das Problem, dass <> nil durchrattert?
  Mit Zitat antworten Zitat
Benutzerbild von Jasocul
Jasocul

Registriert seit: 22. Sep 2004
Ort: Delmenhorst
1.374 Beiträge
 
Delphi 11 Alexandria
 
#3

AW: Abfrage ob GUI Control noch vorhanden ist.

  Alt 24. Mai 2017, 14:43
Ja. Wenn die Komponente nur noch auf der Form arbeitet, kann sie nicht mehr auf controls zugreifen, wenn die Form mit Free entfernt wurde.
Peter
  Mit Zitat antworten Zitat
SneakyBagels
(Gast)

n/a Beiträge
 
#4

AW: Abfrage ob GUI Control noch vorhanden ist.

  Alt 24. Mai 2017, 14:47
Man könnte aber auch vorher prüfen, ob die Form noch existiert oder eher nicht?
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.660 Beiträge
 
Delphi 12 Athens
 
#5

AW: Abfrage ob GUI Control noch vorhanden ist.

  Alt 24. Mai 2017, 15:02
Ein Dangling Pointer bleibt ein Dangling Pointer, egal welcher Typ dahintersteckt. Vielleicht könnte man aber überprüfen, ob das Fensterhandle von ActiveControl noch gültig ist.
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.399 Beiträge
 
Delphi 12 Athens
 
#6

AW: Abfrage ob GUI Control noch vorhanden ist.

  Alt 24. Mai 2017, 15:05
Delphi-Quellcode:
uses Contnrs;

var originalColor : TColor;
    CheckFree: TComponentList;
Delphi-Quellcode:
LastFocused := xxx;
CheckFree.Add(LastFocused);
Delphi-Quellcode:
if CheckFree.IndexOf(LastFocused) >= 0 then
  LastFocused.Color := xxx;
Wird ein Objekt freigegeben, dann löscht es sich selber aus dieser Liste raus.
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
stalkingwolf

Registriert seit: 6. Mai 2011
552 Beiträge
 
#7

AW: Abfrage ob GUI Control noch vorhanden ist.

  Alt 24. Mai 2017, 15:18
Delphi-Quellcode:
uses Contnrs;

var originalColor : TColor;
    CheckFree: TComponentList;
Delphi-Quellcode:
LastFocused := xxx;
CheckFree.Add(LastFocused);
Delphi-Quellcode:
if CheckFree.IndexOf(LastFocused) >= 0 then
  LastFocused.Color := xxx;
Wird ein Objekt freigegeben, dann löscht es sich selber aus dieser Liste raus.
Danke
Damit funktioniert es.
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.399 Beiträge
 
Delphi 12 Athens
 
#8

AW: Abfrage ob GUI Control noch vorhanden ist.

  Alt 24. Mai 2017, 15:31
TComponent.FreeNotification + TComponent.Notification
Wenn man das selber implementieren will.
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
stalkingwolf

Registriert seit: 6. Mai 2011
552 Beiträge
 
#9

AW: Abfrage ob GUI Control noch vorhanden ist.

  Alt 24. Mai 2017, 15:09
Die Abfrage hätte darin nichts zu suchen. Das ganze soll universell überall dort funktionieren wo unsere TDataModul eingebunden wird.
Wie oben geschrieben gab dies in Delph6 übersetzen Programmen auch nie ein Problem.
Das tritt erst auf seitdem wir Programme auf XE4 portiert haben.

try .. except bringt übrigens nichts. Das ist ja schon drin, ich hatte nur noch 2 abfragen davor gesetzt.

Eine eigene Komponenten dafür zu schreiben ist nachträglich nicht so leicht umsetzbar. Wir haben hunderte wenn nicht tausend Forms.
Vor allem so muss sich keiner Gedanken darum machen und es funktioniert auch sehr gut.
  Mit Zitat antworten Zitat
Benutzerbild von Jasocul
Jasocul

Registriert seit: 22. Sep 2004
Ort: Delmenhorst
1.374 Beiträge
 
Delphi 11 Alexandria
 
#10

AW: Abfrage ob GUI Control noch vorhanden ist.

  Alt 24. Mai 2017, 15:15
Das try musst du dann schon ganz an den Anfang setzen. Also noch vor if Sender <> nil
Peter
  Mit Zitat antworten Zitat
Antwort Antwort

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

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 08:09 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