Autor Beitrag
Hagbard
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP Home / Pro
D7.1 Architekt
BeitragVerfasst: Fr 28.05.04 17:42 
Hallo zusammen,

kann mir jemand sagen, wie Ich wenn Ich eine Form schließe eine Wert
vom Typ Integer oder Boolean zurückgeben kann???

Ich öffne die Form mit
ausblenden Quelltext
1:
frmBlaBla.ShowModal;					


Viele Grüße,
Christian
Pascal
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 155

Win 98, Win XP
Delphi 2005, Delphi 5
BeitragVerfasst: Fr 28.05.04 17:52 
Du kannst eine Variable Rückgabewert definieren, OnClose dieser Variable einen Wert zuweisen, und diesen dann nach dem frmblabla.showmodal abfragen.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 28.05.04 18:03 
Hallo!

Das brauchst Du gar nicht. Du kannst der Form, die Du mit ShowModal anzeigst, ein ModalResult (Form2.ModalResult := ...) zuweisen. Durch Zuweisung eines ModalResults wird die Form geschlossen und ShowModal (if Form2.ShowModal = ...) gibt in der aufrufenden Prozedur den entsprechenden Wert zurück!

MfG
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Hagbard Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP Home / Pro
D7.1 Architekt
BeitragVerfasst: Sa 29.05.04 14:37 
Vielen Dank!!! :-)
Pott
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

Windows
Delphi 5
BeitragVerfasst: Mi 30.11.05 09:40 
Titel: Dialog: Kein richtiger Rückgabewert von ModalResult.
Genau das geht bei mir nicht!!!!

Abhängig davon, welchen Schalter ich drücke soll mrOk oder mrCancel vom Dialog-Formular zurückgegeben werden.
Ich erhalte aber immer den Wert 2 als Rückgabewert, egal welchen Button ich klicke.

Rückgabeprüfung:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
  if rfDialog.ModalResult = mrOK then
    ShowMessage('Ok')
  else
    ShowMessage('Nicht Ok');


Ich habe bereits im Dialog-Formular:
ausblenden Delphi-Quelltext
1:
2:
  BtnCancel.ModalResult:=mrCancel;
  BtnOk.ModalResult:=mrOk;


gesetzt.

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
Pott
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

Windows
Delphi 5
BeitragVerfasst: Mi 30.11.05 10:36 
Titel: ModalResult funktioniert von selbst.
Ich weiß nicht warum, aber in meinem Programm
funktionert mrOk und mrCancel ohne, dass ich ModalResult abfrage.

Vermutlich arbeitet die Prozedur, die den Dialog aufruft, nichts mehr ab und springt einfach aus dieser Prozedur.