Autor Beitrag
alex_id
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73



BeitragVerfasst: Di 25.03.03 06:48 
Hi

Da ich mein Programm in den taskmanager einbinden möchte soll es sich nach getaner Arbeit selbst schliessen!!!
Aber wie ??? :( Denn mit "Form1.Close" geht es nicht denn ich hab es mit einen einfachen Programm getestet zB : müsste sich folgendes Programm sofort nach dem Start wieder selbst beenden :
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
unit test;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
   Form1.close;
end;
end.


oder muss ich das auf eine andere Art und Weise tun :?:
Alex
BungeeBug
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 901



BeitragVerfasst: Di 25.03.03 07:47 
Hi
ich würde Application.Terminate; nehmen, das sollte (wenn ich mich nicht irre) die entsprechende Windowsfunktion sein die das erledigt

MfG BungeeBug
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Di 25.03.03 08:29 
Application.Terminate sollte nach Möglichkeit nicht verwendet werden, da in diesem Fall nur eine WM_QUIT Message erzeugt wird (genauere Erläuterung dazu hab ich schon mehrmals gepostet. Bei Interesse einfach suchen...)

Zu dem Thema Formular im OnCreate-Ereignis schließen gab es auch schonmal eine längere Diskussion (gelle Popov? :wink:)
Meine favorisierte Methode in diesem Fall ist
ausblenden Quelltext
1:
PostMessage(Handle, WM_CLOSE, 0, 0);					

Aber auch hier gilt einfach mal die Suchfunktion anwerfen...

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 25.03.03 12:30 
Also ich würde das Hauptfenster schließen und fertig.

Gruß
Tino
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Di 25.03.03 14:44 
Tino hat folgendes geschrieben:
Also ich würde das Hauptfenster schließen und fertig.

Gruß
Tino

Es gibt aber Situationen in denen ein Aufruf von Close nicht funktioniert (aus welchen Gründen auch immer...). War bei mir schon mehrmals der Fall, aber die Methode mit PostMessage funktioniert jedesmal perfekt...

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 25.03.03 14:56 
Sieht so aus, als wenn du das Fenster gar nicht brauchst, da du es im OnCreate-Ereignis gleich wieder schließt. Dann mach doch eine Konsolen-Anwendung. Oder noch nicht mal das und entfern die Unit des Formulares aus deinem Programm und schreib deinen Code in die Projekt-Datei.


Zuletzt bearbeitet von Luckie am Di 25.03.03 15:03, insgesamt 1-mal bearbeitet
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 25.03.03 15:01 
Motzi hat folgendes geschrieben:
Es gibt aber Situationen in denen ein Aufruf von Close nicht funktioniert

Bei mir hat es bislang immer funktioniert.

Gruß
Tino
alex_id Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73



BeitragVerfasst: Mi 26.03.03 01:34 
Hi Leute

Danke für die Tips !!!

Ich habe mich für die Variante von "BungeeBug" entschlossen und es funktioniert wunderbar !!! (Application.Terminate;)

danke

Alex

_________________
Es gibt viele Wege, doch man kann nur einen gehen!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 26.03.03 01:35 
Warum hast du ein Fenster, wenn du es nicht brauchst?
alex_id Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73



BeitragVerfasst: Mi 26.03.03 01:44 
Hi Luckie

Da mit nur einem Fenster war nur ein Beispiel !!!
Ich will ein paar informationen anzeigen und dann soll sich das Prog von selber schließen ... ich weiß klingt etwas umständlich :roll:
aber ich hätte es auch ohne diese Informationen machen können, aber nur durch probieren lernt man mehr :D

Alex

_________________
Es gibt viele Wege, doch man kann nur einen gehen!
recall
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 449



BeitragVerfasst: So 10.08.03 14:46 
Hallo,

hmm... ich bin gerade auf den Beitrag gestoßen und hatte den ersten Quelltext gelesen:

On Create => Form1.Close;

Wie soll man denn ein Formluar schließen, das noch gar nicht erzeugt wurde ???

Daher tippe ich mal, dass hier der Aufruf von Close nicht funktioniert (@Tino)

Viele Grüsse.

P.S.: Der Aufruf geht auch nicht in OnShow, weiß jemand wieso ?
Das Fenster existiert ja schon nur ists halt nicht sichtbar :)
UC-Chewie
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 531

WinXP
D5 Ent
BeitragVerfasst: So 10.08.03 15:44 
Im OnCreate-Ereignis ist das Fenster im Übrigen schon erzeugt.

_________________
Egal wie dumm man selbst ist, es gibt immer andere, die noch dümmer sind
recall
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 449



BeitragVerfasst: So 10.08.03 17:43 
Woher weisst du das ?

Auszug aus der Delphi-Hilfe:
Zitat:
Use OnCreate to perform special processing when the form is created ...


Ist das jetzt wirklich schon erzeugt ?
Wenn ich es übersetze, dann heisst das: Während es erzeugt wird !? :(

Viele Grüsse.
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: So 10.08.03 18:35 
Es ist noch nicht sichtbar. Das Fensterhandle existiert aber bereits.

_________________
Ist Zeit wirklich Geld?