Hallo,
Ich habe eine dynamische Form und ich möchte gern nach 8 Sekunden die Form automatisch schließen!
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39:
| .. type TFormDy = class(TForm) private
published procedure OpFormClose(Sender: TObject; var Action: TCloseAction); procedure OpOnShow(Sender: TObject); procedure OpTimer1Timer(Sender: TObject); procedure ShowFormDy(sTxt: string); end; var FormDy: TFormDy; Count: integer; Timer1: TTimer;
implementation ... ...
procedure TFormDy.ShowFormDyn(sTxt: string); var Fdy: TForm; begin Fdy := TForm.Create(nil); try .. Fdy.OnClose := OpFormClose; Fdy.OnShow := OpOnShow; .. Fdy.ShowModal; finally Fdy.Free; end; end; |
Ich habe versucht mit einem timer aber ich bekomme einen
error: raised exception class EAccessViolation , was soll ich Verbessern?
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
| procedure TFormDy.OpOnShow(Sender: TObject); begin Count := 0; Timer1 := TTimer.Create(nil); Timer1.OnTimer := OpTimer1Timer; Timer1.Interval := 1000; Timer1.Enabled := True; end; procedure TFormDy.OpTimer1Timer(Sender: TObject); begin Inc(Count); if Count > 8 then TForm(Sender).Close; end; |
Ich bedanke mich herzlich für Ihre Unterstützung.