Autor Beitrag
Thunder
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 145

WinXP
D6 Pers
BeitragVerfasst: So 16.11.03 21:42 
Hallo,

Ich habe 2 TTimer. Ein zum Fade-in und einem zum Fade-out.

Zuerst Fade-in:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.TransEinTimerTimer(Sender: TObject);
begin
  Form1.AlphaBlendValue := Form1.AlphaBlendValue + 5;
  If Form1.AlphaBlendValue = 255 then
    begin
      TransEinTimer.Enabled := False;
      Form1.Show;
    end;
end;

Und das wird so aufgerufen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.FormShow(Sender: TObject);
begin
  Form1.AlphaBlendValue := 0;
  Form1.AlphaBlend := True;
  TransEinTimer.Enabled := True;
end;

So und jetz der Problemfall. Das Fade-out will net funzen.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.TransAusTimerTimer(Sender: TObject);
begin
  Form1.AlphaBlendValue := Form1.AlphaBlendValue - 5;
  If Form1.AlphaBlendValue = 0 then
    begin
      TransAusTimer.Enabled := False;
    end;
end;

Und der wird so aufgerufen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.FormHide(Sender: TObject);
begin
  Form1.AlphaBlendValue := 255;
  Form1.AlphaBlend := True;
  TransAusTimer.Enabled := True;
end;

genau den gleichen code habe ich auch bei OnClose, OnDestroy und OnCloseQuery.

Aber egal wie ich mein proggi beende, die Form is direkt weg und fadet net langsam aus. bitte helft mir.

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.
Phantom1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 390



BeitragVerfasst: Mo 17.11.03 10:01 
Wenn du Form1.Close aufrufst wird die Form sofort geschlossen, der Timer wird in diesem fall nicht einmal aufgerufen.

Es gibt mehrere lösungen zu diesem Problem, hier ist mal eine davon:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  AlphaBlendValue := 255;
  AlphaBlend := True;
  TransAusTimer.Enabled := True;
  While TransAusTimer.Enabled Do
    Application.ProcessMessages;
end;

procedure TForm1.TransAusTimerTimer(Sender: TObject);
begin
  alphablendvalue:=alphablendvalue-5;
  If AlphaBlendValue = 0 then
    TransAusTimer.Enabled := False;
end;
Thunder Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 145

WinXP
D6 Pers
BeitragVerfasst: Mo 17.11.03 19:28 
danke. es funktioniert!