Autor Beitrag
patmann2001
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 201

Windows 7 Prof.
Delphi XE2
BeitragVerfasst: Mi 21.08.02 11:57 
Hallo
Wenn man denn opendialog1 unter Delphi (4) aufrufen möchte gibt man ein
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
If opendialog1.execute then
  BEGIN
    -Anweisung-
    -Anweisung-
    -Anweisung-
    -Anweisung-
  END;


Ich habe nun eine eigene Form erstellt und möchte, das sie sich genauso verhält. Sprich:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
If form1.execute then
  BEGIN
    -Anweisung-
    -Anweisung-
    -Anweisung-
    -Anweisung-
  END;


wie mache ich das?

cu Patmann
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Mi 21.08.02 12:06 
Hallo,

du must deinem Formular einfach eine Funktion Execute Verpassen.

Dafür schreibst du unter Public einfach:
ausblenden Quelltext
1:
2:
public
  function Execute : Boolean;


die funktion musst du natürlich ausprogrammieren. Z.b. so:
ausblenden Quelltext
1:
2:
3:
4:
function tMyOpenDialog.Execute : Boolean;
begin
  Result := ShowModal = mrOK;
end;


Diese darf natürlich auch Komplexer werden.

Gruß
Klabautermann
patmann2001 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 201

Windows 7 Prof.
Delphi XE2
BeitragVerfasst: Mi 21.08.02 13:05 
Hi
Ich habe da aber jetzt ein Problem:
ausblenden Quelltext
1:
2:
3:
public
   function execute:Boolean;
   wort:STRING;

Die Variable hatte ich vorher schon in Public stehen. Jetzt bekomme ich Fehlermeldungen:
Zitat:

[Fehler] Felddefinition nicht erlaubt nach Methoden oder Eigenschaften


Wenn ich die Deklaration undrehe bekomme ich
Zitat:

[Fehler] Ungenügende Forward- oder External-Deklaration: 'form1.execute'

Wenn ich dann Forward; anhänge bekomme ich wieder den ersten Fehler.
Ein VAR vor wort:STRING; nützt auch nichts.
Was jetzt?
cu Patmann
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Mi 21.08.02 13:41 
Hallo,

patmann2001 hat folgendes geschrieben:
Wenn ich die Deklaration undrehe bekomme ich
Zitat:

[Fehler] Ungenügende Forward- oder External-Deklaration: 'form1.execute'


das mit dem Umdrehen ist schon richtig. Du must die Funktion nur wie oben Dargestellt auch ausprogrammieren (im implementation anschnit). Wenn du eine neuere Delphi Pro (oder besser) Version hast musst du nur auf die neue Zeile gehen und Strg+Shif+C drücken, dann wird dir ein leerer Funktionsrumf automatisch eingefügt.

Gruß
Klabautermann
lemming
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 470

Mac OS 10.3.1
Delphi 6 Pro, Kylix 3
BeitragVerfasst: Mi 21.08.02 13:57 
Du kannst dieses Formular auch Modal aufrufen. D.h. deine hintere Anwendung "friert" in gewisser Weise ein bis das Formular sich schliesst.

Zitat:
Form1.ShowModal;


Dann solltest du halt noch irgendwie prüfen ob der user auf Abbrechen geklickt hat. Z.B. ein public Boolean in Form1 einfügen.

Bisschen Stümperhaft, aber funktionsfähig
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Mi 21.08.02 14:53 
@lemming:

Was alles in der funktion:
ausblenden Quelltext
1:
2:
3:
4:
function tMyOpenDialog.Execute : Boolean; 
begin 
 Result := ShowModal = mrOK; 
end;

passiert ;).

Gruß
Klabautermann
lemming
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 470

Mac OS 10.3.1
Delphi 6 Pro, Kylix 3
BeitragVerfasst: Mi 21.08.02 16:06 
Rofl, :lol:

Sorry, manchmal überfliege ich die Texte wohl wirklich ein bisschen zu schnell :oops:
patmann2001 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 201

Windows 7 Prof.
Delphi XE2
BeitragVerfasst: Mi 21.08.02 21:33 
Tja
Leider bekomme ich auch weiterhin eine Fehlermeldung wenn ich versuche Variablen und Proceduren/Functionen im Public Teil gemeinsam zu erstellen. :cry:
Macht aber nicht, ich habe das jetzt so gelöst wie lemming es vorgeschlagen hat und es klappt damit ganz prima.
Danke schön :lol:

cu Patmann