Delphi-PRAXiS
Seite 2 von 3     12 3      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Abfrage ob Pogramm geschlossen werden soll. (https://www.delphipraxis.net/122871-abfrage-ob-pogramm-geschlossen-werden-soll.html)

Sven M. 23. Okt 2008 15:29

Re: Abfrage ob Pogramm geschlossen werden soll.
 
Zitat:

Zitat von Progman
Versuchs mal im CloseQuery:

Delphi-Quellcode:
if MessageDlg('Programm schließen?', mtConfirmation, [mbyes, mbno], 0) = mrYes then
 CanClose := True else CanClose := False;


Habe auch im Moment ein paar Problemchen mit dem ordnungsgemäßen Schließen des Programms. Das Problem: Wenn ich es genau so mache wie oben, ist die Anwendung zwar weg, steht aber im Taskmanager noch drin. Hat jemand 'ne Ahnung, woran das liegt?


Besten Dank im Voraus,
Sven M.

DeddyH 23. Okt 2008 15:31

Re: Abfrage ob Pogramm geschlossen werden soll.
 
Tritt das Phänomen auch dann auf, wenn Du oben zitierten Code auskommentierst?

Sven M. 23. Okt 2008 15:41

Re: Abfrage ob Pogramm geschlossen werden soll.
 
Ja, auch dann!

Kann es eventuell daran liegen, dass das Fenster, aus dem ich das Programm beenden möchte, nicht das im Projektmanager eingestellte Hauptfenster ist?


Dann hätte ich das nächste Problem: Wie kann ich abfragen, von wo aus einer Procedure aufgerufen wird. Denn im OnCloseQuery des Hauptformulars müsste ich ja dann den Fall abfangen, dass ich das Programm beenden möchte oder nur das Fenster schließen will...Verwirrend...;)

SirThornberry 23. Okt 2008 15:42

Re: Abfrage ob Pogramm geschlossen werden soll.
 
@Seven: Das kommt in aller Regel vor wenn man mit Threads hantiert und da noch einer läuft oder man mit Application.Processmessages Nachrichten abarbeitet während man noch in einer Schleife hängt.

Sven M. 24. Okt 2008 07:52

Re: Abfrage ob Pogramm geschlossen werden soll.
 
Hab's gefunden...=)

Lag tatsächlich daran, dass ich das Programm von einem anderen als dem Hauptfesnter (in den Projektoptionen) aus schließen wollte.
Hab's jetzt so gelöst, dass das eigentliche Hauptfenster (aus User-Sicht) auch das Hauptfenster in den Projektoptionen ist und das Fenster, das beim Start angezeigt werden soll (deswegen war's das Hauptfenster) über einen Timer geöffnet wird...:)

Micha88 24. Okt 2008 08:49

Re: Abfrage ob Pogramm geschlossen werden soll.
 
Also ich persönlich mag den MessageDlg nicht so :gruebel:


Ich mache das immer so:

Delphi-Quellcode:
procedure THaupt.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 if (Application.MessageBox('Sind Sie sicher, dass Sie diese Anwendung schließen möchten?', 'Information', MB_IconInformation + MB_YesNo) = ID_Yes) then
  begin
   // ggf. alles freigeben, Bitmaps, SL's usw
   Self.Close; // ENDE!
  end;
end;

Sven M. 24. Okt 2008 09:10

Re: Abfrage ob Pogramm geschlossen werden soll.
 
Hat das bestimmte Gründe?

DeddyH 24. Okt 2008 09:22

Re: Abfrage ob Pogramm geschlossen werden soll.
 
Eine MessageBox wird von Windows gezeichnet, ein MessageDlg von Delphi.

Cicaro 21. Feb 2010 15:20

Re: Abfrage ob Pogramm geschlossen werden soll.
 
Geht diese Abfrage auch modal ?

Edit: Schon gut, ist schon standardmäßig modal. Bei mir wird die Abfrage durch einen Timer mehrmals aufgerufen. Muss nur den Timer ausschaten, damit die Abfrage nicht nochmal erfolgt.

DeddyH 21. Feb 2010 15:28

Re: Abfrage ob Pogramm geschlossen werden soll.
 
Die Windows.MessageBox zumindest geht auch modal MSDN-Library durchsuchenMessageBox.
Zitat:

To indicate the modality of the dialog box, specify one of the following values.

MB_APPLMODAL
The user must respond to the message box before continuing work in the window identified by the hWnd parameter. However, the user can move to the windows of other threads and work in those windows.

Depending on the hierarchy of windows in the application, the user may be able to move to other windows within the thread. All child windows of the parent of the message box are automatically disabled, but pop-up windows are not.

MB_APPLMODAL is the default if neither MB_SYSTEMMODAL nor MB_TASKMODAL is specified.
MB_SYSTEMMODAL
Same as MB_APPLMODAL except that the message box has the WS_EX_TOPMOST style. Use system-modal message boxes to notify the user of serious, potentially damaging errors that require immediate attention (for example, running out of memory). This flag has no effect on the user's ability to interact with windows other than those associated with hWnd.
MB_TASKMODAL
Same as MB_APPLMODAL except that all the top-level windows belonging to the current thread are disabled if the hWnd parameter is NULL. Use this flag when the calling application or library does not have a window handle available but still needs to prevent input to other windows in the calling thread without suspending other threads.


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:30 Uhr.
Seite 2 von 3     12 3      

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