Autor Beitrag
KyroxX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Fr 16.05.03 12:22 
Hi, wie kann ich eine animierte Transparenz realisieren?

Also wie etwa so:

Alpha Blend 1 nach 0.001 Sekunden dann 2 usw bis 255

Ich möchte damit einen startscreen realisieren. Also eine Rahmenlose Form mit einer Startgrafik. Dazu spielt ein Sound. Wenn der zu ende is, sind etwa 20sek, soll das febste transparent "faden" und sich dann schiessen.

Alles is kein problem nur eben das Faden würd mir 2000 codezeilen fabrizieren :twisted: wenn ich da dann mit pause / wait usw ran gehen muss.

Gibbts da keine "professionellere" lösung? :wink:

Naja THX für Antwort im vorraus ;)

Bya

_________________
KyroxX :: Have a lot of Fun !
ase
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 203

Gentoo, Windows 9X, ME, 2k, NT, XP
Delphi 7 Prof., PHP 5 (Eclipse 3 SDK)
BeitragVerfasst: Fr 16.05.03 12:46 
gibt es.

ich habe mir einen thread geschrieben, der als parameter das fenster und noch andere werte (speed, von-wert, bis-wert usw) übergeben bekommt. bei form.show wird dann der thread aktiviert und der setzt dann entsprechend seiner parameter AlphaBlendValue langsam hoch.

klappt aber nicht bei win 9X!!


ase

_________________
-EN
KyroxX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Fr 16.05.03 21:04 
Titel: hmm
könntest du den code wohl hier einfügen?

Wär echt cool ;)

Is übrigensder Startscreen von meinem Editor ;)
Dem MIDE ;) @ www.m-ide.tk hab ich auch schon gefuscht *gg*

Nuja jetzt muss erstmal des Hauptprogramm in die Alpha Phase *g*g*
8)

_________________
KyroxX :: Have a lot of Fun !
ase
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 203

Gentoo, Windows 9X, ME, 2k, NT, XP
Delphi 7 Prof., PHP 5 (Eclipse 3 SDK)
BeitragVerfasst: Fr 16.05.03 21:29 
nah.. net so gern. hab doch geschrieben wie es geht, kannst du dir doch nen eigenen thread schreiben oder?!?! :oops:


ase

_________________
-EN
KyroxX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Fr 16.05.03 23:58 
Hmm was häls du vond er möglichkeit?
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:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
TMyForm = class (TForm); 

TrackBar1: TTrackBar; 
//.. 
private 
FColorKey: TCOLOR; 

end; 

const 
  // Use crKey as the transparency color. 
  LWA_COLORKEY = 1; 
  // Use bAlpha to determine the opacity of the layered window.. 
  LWA_ALPHA     = 2; 
  WS_EX_LAYERED = $80000; 

implementation 

{$R *.DFM} 

// The SetLayeredWindowAttributes function sets the opacity and transparency 
// color key of a layered window. 
// Note : This function is only available with Windows 2000 and XP! 
function SetLayeredWindowAttributes( 
  // Handle to the layered window. 
  Wnd: hwnd; 
  // Pointer to a COLORREF value that specifies the transparency 
  // color key to be used when composing the layered window 
  crKey: ColorRef; 
  // Alpha value used to describe the opacity of the layered window 
  Alpha: Byte; 
  // Specifies an action to take 
  // LWA_COLORKEY or LWA_ALPHA 
  // This parameter can be one or more of the following values: 
  dwFlags: DWORD): Boolean; 
  stdcall; external 'user32.dll'; 


procedure TMyForm.TrackBar1Change(Sender: TObject); 
  // Trackbar.Position must run at range 1-255... 
begin 
  SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_LAYERED); 
  SetLayeredWindowAttributes(Handle, ColorToRGB(FColorKey), TrackBar1.Position, LWA_ALPHA); 
end; 

{******************************************************************} 

{ To load the SetLayeredWindowAttributes() function dynamically, use this function:} 

function MakeWindowTransparent(Wnd: HWND; nAlpha: Integer = 10): Boolean; 
type 
  TSetLayeredWindowAttributes = function(hwnd: HWND; crKey: COLORREF; bAlpha: Byte; 
    dwFlags: Longint): Longint;  
  stdcall; 
const 
  // Use crKey as the transparency color. 
  LWA_COLORKEY = 1; 
  // Use bAlpha to determine the opacity of the layered window.. 
  LWA_ALPHA     = 2; 
  WS_EX_LAYERED = $80000; 
var 
  hUser32: HMODULE; 
  SetLayeredWindowAttributes: TSetLayeredWindowAttributes; 
  i: Integer; 
begin 
  Result := False; 
  // Here we import the function from USER32.DLL 
  hUser32 := GetModuleHandle('USER32.DLL'); 
  if hUser32 <> 0 then 
  begin @SetLayeredWindowAttributes := GetProcAddress(hUser32, 'SetLayeredWindowAttributes'); 
    // If the import did not succeed, make sure your app can handle it! 
    if @SetLayeredWindowAttributes <> nil then 
    begin 
      // Check the current state of the dialog, and then add the WS_EX_LAYERED attribute 
      SetWindowLong(Wnd, GWL_EXSTYLE, GetWindowLong(Wnd, GWL_EXSTYLE) or WS_EX_LAYERED); 
      // The SetLayeredWindowAttributes function sets the opacity and 
      // transparency color key of a layered window 
      SetLayeredWindowAttributes(Wnd, 0, Trunc((255 / 100) * (100 - nAlpha)), LWA_ALPHA); 
      Result := True; 
    end; 
  end; 
end;

Hab ich auf irgendner site gefunden ;) abba noch nioch ausprobiert *gg*

_________________
KyroxX :: Have a lot of Fun !
Thunder
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 145

WinXP
D6 Pers
BeitragVerfasst: So 16.11.03 21:36 
Wieso bastelst du das net innen TTimer. Hab ich auch. Bei onShow wird der Timer enabled und dann setzt der timer blendvalue hoch. wenn er bei 255 angekommen is disabled er sich selber (timer.enabled := false).

fertig
ase
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 203

Gentoo, Windows 9X, ME, 2k, NT, XP
Delphi 7 Prof., PHP 5 (Eclipse 3 SDK)
BeitragVerfasst: So 16.11.03 22:24 
servus

TTimer ist so eine... naja lösung. TTimer arbeitet mit botschaften. Somit ist das timer intervall nicht regelmäßig und wenn deine anwendung viel arbeitet während der intialisierung, dann kann es passiern das dein splash screen ruckelhaft bis garnicht angezeigt bekommt. ttimer ist da keine elegante lösung. nimm nen thread!

Das was du da oben gepostet hast ist genau das was du brauchst. das habe ich in meinen thread gepackt. nachteil davon ist, dass es nur ab win2k geht. anders wirst du es aber kaum hinbekommen.


ase

_________________
-EN
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 17.11.03 17:27 
Titel: Bemerkung
Hallo!

Nur weil hier immer wieder gesagt wurde, dass der angegebene Code nur unter 2k oder XP läuft:

Unter Windows 9x hat der Wert von AlphaBlendValue ohnehin keine Bedeutung! Das heißt man müsste diesen Effekt komplett per Hand progammieren. Das habe ich mal versucht, aber es dann aufgegeben.

Daher glaube ich nicht, dass es eine sinnvolle Möglichkeit für 9x überhaupt gibt, da diese alten OS diesen Effekt noch nicht unterstützen!

Na ja, und zu 2k und XP wurde ja bereits gesagt, wie das funktioniert!

Ich möchte nur noch einmal auf den Timer zurückkommen:
Ich weiß, dass es einen genauen Timer gibt, der unabhängig von den Systembotschaften arbeitet, oder so, der jedenfalls wirklich immer zu der genauen Zeit das Ereignis auslöst!
Leider fällt mir im Moment nicht ein, wie der angesprochen werden kann!

Ich werde danach suchen, und vielleicht weiß es ja auch bevor ich das finde jemand anderes...
(Das wäre nämlich eine zwar nicht sonderlich elegante :roll: , aber sehr einfache 8) Möglichkeit)

MfG,
S.J.
Zimond
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 49



BeitragVerfasst: Mi 27.10.04 16:40 
was passiert dann eigentlich mit Programmen die eine alpha geblendete form haben auf win9x?
bleibt die form dann einfach nur komplett undurchsichtig und sonst passiert nichts oder gibt es eine fehlermeldung?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 28.10.04 07:33 
Das Fenster wird einfach überhaupt nicht transparent gezeichnet, d.h. es ist immer sichtbar!
Das transparente Zeichnen muss aktiviert werden (vom Code, der TForm zugrunde liegt), und das wird es unter Win9x/ME einfach nicht.