Autor Beitrag
Radioactive
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179

Win 98, Win XP Home SP2
D3 Prof, D7 Pers, D2005 Pers
BeitragVerfasst: Mo 06.12.04 17:02 
Hi Leute!

Ich lasse eine Form mit Alphablend wie in [url=www.delphi-forum.de/...b4d0a70803d3e18d22a]
Begrüssungsform langsam einblenden lassen ![/url]
ausblenden. Nun will ich das ganze aber auch beim einblenden machen. Leider hat der Autor nicht dazugeschrieben, in welche procedure der Quelltext zum einblenden reingehört.
Wenn ich ihn in die FormCreate-Methode hinzufüge, sehe ich nichts, weil die Form da ja noch Createt wird.
Als "Lösung" habe ich es in die FormActivate-Methode geschrieben und überprüfe mit einem Boolean, ob es die FormActivate-Methode das erste mal ausgeführt wird. Wenn ja, lasse ich ihn AlphaBlend machen. (AlphaBlend wird in FormCreate auf true gesetzt und AlphaBlendValue auf 0).
Jetzt die Frage: Ist das so richtig oder ist das schlampig programmiert?

Achja: Ich habe im Forum nach alternativen Lösungen gesucht, aber nichts brauchbares gefunden. Sollte ich was übersehen haben, dann sagt es mir.

Thx schon mal im Vorraus,
Radioactive
st-matze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 138

Win 3.11, Win 95, Win 98, Win XP
D7 Ent, D6 Pers, (D5 Pers)
BeitragVerfasst: Mo 06.12.04 17:25 
Tform.OnShow
Radioactive Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179

Win 98, Win XP Home SP2
D3 Prof, D7 Pers, D2005 Pers
BeitragVerfasst: Mo 06.12.04 19:53 
Das habe ich auch schon versucht, funktioniert aber auch nicht.
st-matze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 138

Win 3.11, Win 95, Win 98, Win XP
D7 Ent, D6 Pers, (D5 Pers)
BeitragVerfasst: Di 07.12.04 12:27 
ausblenden volle Höhe Delphi-Quelltext
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:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);

const stepsize = 5;

  function Min(a,b:integer):integer;
  begin
    if a<b then Result:=a
    else Result:=b;
  end;

begin
  if AlphaBlendValue=255 then
  begin
    AlphaBlend:=false;
    Timer1.Enabled:=false;
  end
  else
    AlphaBlendValue:=Min(AlphaBlendValue + stepsize, 255);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  Timer1.Enabled:=true;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Timer1.Enabled:=false;
  Timer1.Interval:=25;
  AlphaBlend:=true;
  AlphaBlendValue:=0;
end;

end.


wenn die Geschwindigkeit nicht passt, kannst ja am Timerintervall oder an der stepsize rumbasteln.
Radioactive Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179

Win 98, Win XP Home SP2
D3 Prof, D7 Pers, D2005 Pers
BeitragVerfasst: Di 07.12.04 17:16 
OK, das geht.
Aber das mit der Min-Funktions kannst du dir sparen, wenn du es so porgranmierst, also statt "=" ein ">=" verwendest:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
if AlphaBlendValue >= 255 then
  begin
    AlphaBlend:=false;
    Timer1.Enabled:=false;
  end
  else
    AlphaBlendValue:= AlphaBlendValue + stepsize;


Danke!
st-matze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 138

Win 3.11, Win 95, Win 98, Win XP
D7 Ent, D6 Pers, (D5 Pers)
BeitragVerfasst: Di 07.12.04 17:26 
das hatte ich extra gemacht, da ALphaBlendValue einen Wertebereich von 0 bis 255 hat. Und ich weiss nicht was passiert, wenn man versucht AlphaBlendValue einen Wert zuzuweisen der größer ist. war zu faul es zu testen.

Ansonsten hast du natürlich recht.
Radioactive Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179

Win 98, Win XP Home SP2
D3 Prof, D7 Pers, D2005 Pers
BeitragVerfasst: Do 09.12.04 16:36 
Dann könnte man Teiler von 255 als stepsize nehmen, also 3,5,17
dann hake ich dieses Thema jetzt ab.