Autor Beitrag
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Sa 18.08.07 17:56 
Hallöle!

Abhängig von der Kommandozeile möchte ich entweder Form1 oder Form2 (Name geändert^^) anzeigen. Das mache ich so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
begin
  Application.Initialize;
  if ParamStr(1)='' then
    Application.CreateForm(TForm1, Form1)
  else
    Application.CreateForm(TForm2, Form2);
  Application.Run;
end.


Nun lässt mich Delphi die Anwendung nicht mehr im Debugger starten (F9) und beschwert so so:
Zitat:
Fehler im Modul Project1: Der Aufruf von Application.CreateForm fehlt oder ist nicht korrekt.

Ich vermute ja mal, dass das daran liegt dass er sich nicht sicher ist, ob immer ein Form erzeugt werden wird. Wird es aber.

Wie kann ich den überreden, da nicht zu meckern? Und sagt jetzt nicht, ein Dummy-Form erzeugen, weil ich hier eigentlich mit kleinstmöglichem Footprint arbeiten wollte...

mfg
Martok

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 18.08.07 18:36 
Schätze, man muss das Hauptformular auf jeden Fall erzeugen, also abhängig vom Parameter ShowMainForm setzen und Form2.Show geg. aufrufen.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Martok Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Sa 18.08.07 18:59 
Tja, es wird ja erzeugt. Entweder das eine, oder das andere.
Nur merkt Delphi das halt nicht. Der soll sich doch bloß aus meiner Projektdatei raushalten. Ich weiß schon, was ich tue ;)

Und beide erzeugen ist doof, weil ich dann mit den FormCreate Probleme kriege.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 18.08.07 19:10 
Kannst du nicht den relevanten Formcreate-Teil an die gleiche Parameterabfrage binden?

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 18.08.07 19:24 
Das ist ein Bug in der Delphi-IDE, die davon ausgeht, dass in der Projekt-Datei mindestens eine Application.CreateForm-Zeile vorkommt, ohne eine Bedingung.

Weiterhin darf es KEINE!!! solche Zeile OHNE abschließendes Semikolon geben.

HTH.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
dummzeuch
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 593
Erhaltene Danke: 5


Delphi 5 ent, Delphi 6 bis Delphi XE8 pro
BeitragVerfasst: Sa 18.08.07 20:45 
user profile iconMartok hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
begin
  Application.Initialize;
  if ParamStr(1)='' then
    Application.CreateForm(TForm1, Form1)
  else
    Application.CreateForm(TForm2, Form2);
  Application.Run;
end.

Zitat:
Fehler im Modul Project1: Der Aufruf von Application.CreateForm fehlt oder ist nicht korrekt.



Da spinnt die IDE rum. Einfachste Loesung: Diesen Code in eine Unit verschieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
unit MainUnit;

uses 
 ...

interface

procedure Main;

implementation

procedure Main;
begin
  Application.Initialize;
  if ParamStr(1)='' then
    Application.CreateForm(TForm1, Form1)
  else
    Application.CreateForm(TForm2, Form2);
  Application.Run;
end;

end.


Und dann im Projekt einfach:

ausblenden Delphi-Quelltext
1:
2:
3:
begin
  Main;
end.