Autor Beitrag
Gewuerzgurke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 152

Win XP
Lazarus
BeitragVerfasst: Mo 03.11.08 19:59 
Ich habe mir ein Fenster mit Einblendeeffekt. Die Funktion, die das Fenster halbtransparent macht, sieht so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
function SetWindowTransparence (Grad: byte; Ziel: THandle) : Boolean;
var
 Info: TOSVersionInfo;
 SetLayeredWindowAttributes: TSetLayeredWindowAttributes;
begin
 AHandle := Ziel;
 AValue := Grad;
 Info.dwOSVersionInfoSize := SizeOf(Info);
 GetVersionEx(Info);
 if (Info.dwPlatformId = VER_PLATFORM_WIN32_NT) and
 (Info.dwMajorVersion >= 5) then begin
  SetLayeredWindowAttributes := GetProcAddress(GetModulehandle(user32),
  'SetLayeredWindowAttributes');
  if Assigned(SetLayeredWindowAttributes) then begin
   SetWindowLong(AHandle, GWL_EXSTYLE, GetWindowLong(AHandle, GWL_EXSTYLE) or
   WS_EX_LAYERED);
   SetLayeredWindowAttributes(AHandle, 0, AValue, LWA_ALPHA);
   Result := true;
  end;
 end else Result := false;
end;

Alle nötigen Variablen, etc. sind außerhalb definiert.
Das geht auch ganz gut, nur verdeckt das Fenster den mit DirectX erzeugten Bereich mit dem angegebenen Tranzparenzgrad.
Soll heißen: Sobald die oben beschriebene SetWindowTransparence - Funktion aufgerufen wurde, wird der mit DirectX erzeugte Inhalt nicht mehr auf das Fenster gerendert, sondern dahinter. (Die Renderprozedur für den DirectX - Inhalt tut jetzt nichts zur Sache)
Aus diesem Sachverhalt schlussfolgere ich, dass ein Befehl in besagter SetWindowTransparence - Funktion etwas am Fenster so verändert, dass dieses Problem auftritt.

Also meine Frage:
Was genau verändert sich und wie kann man das Rückgängig machen?

Wenn also jemand einfach ein Paar Zeilen hätte, die bewirken, dass alles in der Anwendung wieder so ist, als währe SetWindowTransparence nie aufgerufen worden, würde dies das Problem in meinem Fall lösen.
Gewuerzgurke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 152

Win XP
Lazarus
BeitragVerfasst: Mi 05.11.08 15:39 
Kennt niemand eine Methode? :cry:
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 09.11.08 01:09 
Die GDI+-Transparenzen und Hardware-Beschleunigte Pixelformate schließen sich AFAIK aus. Zeig mal nen Screenshot wie's aussieht, bzw. wie's aussehen sollte.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Gewuerzgurke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 152

Win XP
Lazarus
BeitragVerfasst: So 09.11.08 14:49 
Also: 1.JPG zeigt das Fenster so, wie es sein soll und wie es nur dann aussieht, wenn es niemals transparent war. 2.JPG zeigt das Fenster, mit 80% Transparenz; der mit DirectX erzeugte Inhalt im Panel lässt sich natürlich nicht tranzparent machen.
3.JPG zeigt das Fenster mit 20% Tranzparenz; hier sieht man deutlich, dass der mit DirectX erzeugte Inhalt jetzt "hinter" das Fenster gerendert wird.
Es hilft übrigens nicht, wenn das Fenster zu 0% tranzparent ist; dann ist der DirectX-Inhalt eben überhaupt nicht zu sehen.
Ich wollte nur wissen, was man machen kann, damit das Fenster nach dem Einblendeeffekt wieder in den Status eines normalen Fensters, wie etwa in 1.JPG, zurückgesetzt wird.
Einloggen, um Attachments anzusehen!
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 09.11.08 15:24 
Die Erklärung, warum das so ist, hab ich ja gegeben ;-)

Zwecks Transparenz wieder abschalten: Versuch mal das Flag was du in Zeile 15f setzt, nach dem Einblenden wieder zu killen.

Alternativ musst Du mit einem PBuffer rendern und diesen Manuell auf die Form mit der GDI BitBlt'n. Damit verlierst Du aber die gesamte DirectX\OpenGL-Beschleunigung ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Gewuerzgurke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 152

Win XP
Lazarus
BeitragVerfasst: So 09.11.08 16:41 
Zitat:
Versuch mal das Flag was du in Zeile 15f setzt, nach dem Einblenden wieder zu killen

Wie geht das? :oops:
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 09.11.08 16:45 
user profile iconGewuerzgurke hat folgendes geschrieben Zum zitierten Posting springen:
Zitat:
Versuch mal das Flag was du in Zeile 15f setzt, nach dem Einblenden wieder zu killen

Wie geht das? :oops:

Einmal dumm angestellt, reicht ... nunja:

ausblenden Delphi-Quelltext
1:
SetWindowLong(AHandle, GWL_EXSTYLE, GetWindowLong(AHandle, GWL_EXSTYLE) and not WS_EX_LAYERED);					


Ungetestet.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Gewuerzgurke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 152

Win XP
Lazarus
BeitragVerfasst: So 09.11.08 16:58 
Ungetestet - Aber es funktioniert. Hab' mir jetzt noch eine ClearWindowTransparence - Funktion gemacht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
function ClearWindowTransparence (Ziel: THandle) : Boolean;
var
 Info: TOSVersionInfo;
begin
 Result := false;
 Info.dwOSVersionInfoSize := SizeOf(Info);
 GetVersionEx(Info);
 if (Info.dwPlatformId = VER_PLATFORM_WIN32_NT) and
  (Info.dwMajorVersion >= 5) then
  SetWindowLong(Ziel, GWL_EXSTYLE, GetWindowLong(Ziel, GWL_EXSTYLE) and
  not WS_EX_LAYERED);
 Result := true;
end;

Jetzt kann ich endlich Einblendeeffekt und DirectX kombinieren :D