Einzelnen Beitrag anzeigen

Benutzerbild von Helmi
Helmi

Registriert seit: 29. Dez 2003
Ort: Erding, Republik Bayern
3.312 Beiträge
 
Delphi XE2 Professional
 
#1

Transparent-Function auch für Win-Versionen unter Win2000?

  Alt 26. Dez 2005, 12:25
Hallo Jungs,

bei den Schweizern hab ich folgenden Code gefunden, um eine Form transparent darstellen zu lassen:
Delphi-Quellcode:
function MakeWindowTransparent(Wnd: HWND; nAlpha: Integer = 10): Boolean;
type
  TSetLayeredWindowAttributes = function(hwnd: HWND; crKey: COLORREF; bAlpha: Byte;
    dwFlags: Longint): Longint; stdcall;
var
  hUser32: HMODULE;
  SetLayeredWindowAttributes: TSetLayeredWindowAttributes;

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;
Nun ist meine Frage, ob diese Function auch unter Win95/98/Me läuft (also alle Windows-Versionen unter Win2000)?
(ich hab momentan keine Möglichkeit dies auf niedrigerer Windowsversionen zu testen)

Ich hätte ja sehr gerne "AlphaBlend" verwendet, nur ist dies laut OH nur ab 2000 lauffähig!
mfg
Helmi

>> Theorie ist Wissen, dass nicht funktioniert - Praxis ist, wenn alles funktioniert und keiner weiss warum! <<
  Mit Zitat antworten Zitat