AGB  ·  Datenschutz  ·  Impressum  







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

close in OnCreate

Ein Thema von Borti · begonnen am 1. Apr 2004 · letzter Beitrag vom 1. Apr 2004
Antwort Antwort
Seite 1 von 2  1 2      
Borti

Registriert seit: 11. Okt 2003
151 Beiträge
 
#1

close in OnCreate

  Alt 1. Apr 2004, 16:45
Hallo1!
Ich hab folgende Passage in meinem Programm:
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
 if not fileexists({dateiname}) then Form1.Close;
end;
d.h.: mein Programm soll sich beim Starten sofort wieder beenden, wenn eine spezielle datei fehlt.
Leider startet das programm trotzdem.
was ist da falsch
Danke,
Borti
Ich hab's versucht
(auch wenn's nicht so aus sieht)
  Mit Zitat antworten Zitat
Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#2

Re: close in OnCreate

  Alt 1. Apr 2004, 16:48
Hi,

Mache die Überprüfung in der Projektedatei:


Delphi-Quellcode:
program Project1;

uses
  Forms,
  SysUtils,
  Unit1 in 'Unit1.pas{Form1};

{$R *.res}


begin
  if not FileExists('{dateiname}') then
    Exit;
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
Thomas
  Mit Zitat antworten Zitat
Benutzerbild von Meflin
Meflin

Registriert seit: 21. Aug 2003
4.856 Beiträge
 
#3

Re: close in OnCreate

  Alt 1. Apr 2004, 16:49
du kannst im oncreate kein close durchführen. nimm statdessen was anderes, z.b. onshow!
[edit]@toms: noch besser![/edit]
  Mit Zitat antworten Zitat
Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#4

Re: close in OnCreate

  Alt 1. Apr 2004, 17:01
Nachtrag:

Wenn die Datei nicht gefunden werden kann, dann
vielleicht noch eine Messagebox mit passender Nachricht anzeigen,
damit der User weiss, warum die App geschlossen wird.
Thomas
  Mit Zitat antworten Zitat
jbg

Registriert seit: 12. Jun 2002
3.481 Beiträge
 
Delphi 10.1 Berlin Professional
 
#5

Re: close in OnCreate

  Alt 1. Apr 2004, 17:32
Alternativ kann man in OnCreate auch folgendes machen:

Delphi-Quellcode:
if not FileExist(x) then
begin
  ShowMessage('Die Datei X wird benötigt');
  Application.ShowMainForm := False;
  Application.Terminate;
  Exit;
end;
...
  Mit Zitat antworten Zitat
citybreaker
(Gast)

n/a Beiträge
 
#6

Re: close in OnCreate

  Alt 1. Apr 2004, 17:33
Für das doch einfach in FormShow() aus. Also da klappt
es bei mir zumindest.
  Mit Zitat antworten Zitat
Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#7

Re: close in OnCreate

  Alt 1. Apr 2004, 17:38
Zitat:
Alternativ kann man in OnCreate auch folgendes machen:
und

Zitat:
Für das doch einfach in FormShow() aus
Warum soll eine Form erstellt werden, wenn sie evtl. gar nie angezeigt wird??
Thomas
  Mit Zitat antworten Zitat
Benutzerbild von Meflin
Meflin

Registriert seit: 21. Aug 2003
4.856 Beiträge
 
#8

Re: close in OnCreate

  Alt 1. Apr 2004, 17:51
leute ihr macht hier grad aus ner mücke nen elephanten...
  Mit Zitat antworten Zitat
Benutzerbild von Evian
Evian

Registriert seit: 10. Apr 2003
Ort: Berlin
485 Beiträge
 
Delphi 6 Professional
 
#9

Re: close in OnCreate

  Alt 1. Apr 2004, 17:51
Zitat von toms:
Warum soll eine Form erstellt werden, wenn sie evtl. gar nie angezeigt wird??
Klever mitgedacht

kannst es auch so machen ->

Code:

program Project1;

uses
  Forms,
  SysUtils,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res} 


begin
  if not FileExists('{dateiname}') then
    Exit ELSE
  BEGIN
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
  END;
end.
dann wird nur die Form erstellt, wenn die Datei da ist.
-> www.Phillsoft.de

Ich bin nun Mathematiker, aber meine Freundin bleibt trotzdem unberechenbar!
  Mit Zitat antworten Zitat
Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#10

Re: close in OnCreate

  Alt 1. Apr 2004, 17:56
@ Evian: Was ist an deinem Code anders als an meinem?
Thomas
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


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 04:41 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz