Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi AlphaBlend für Delphi 5 Prof. (https://www.delphipraxis.net/52968-alphablend-fuer-delphi-5-prof.html)

Nils_13 7. Sep 2005 15:34


AlphaBlend für Delphi 5 Prof.
 
Hi,

wie kann ich eine AlphaBlend in Delphi5 benutzen.

Wenn ich das dann in eine Kompo setze, welchen Vorfahrtyp könnte ich nehmen ?

MarcoWarm 7. Sep 2005 15:51

Re: AlphaBlend für Delphi 5 Prof.
 
so sollte es klappen :)

https://www.planet-source-code.com/v...d=649&lngWId=7

Nils_13 7. Sep 2005 15:56

Re: AlphaBlend für Delphi 5 Prof.
 
Cool, thx !

Mit
Delphi-Quellcode:
var i : integer;
begin
  for i := 100 downto 0 do
  begin
    MakeTransparent(Handle,i);
    Application.ProcessMessages;
  end;
  Close;
Lass ich die Form verschwinden, nur wie lasse ich sie so erscheinen ?

MarcoWarm 7. Sep 2005 16:01

Re: AlphaBlend für Delphi 5 Prof.
 
Delphi-Quellcode:
  for i := 0 to 100 do
  begin
    MakeTransparent(Handle,i);
    Application.ProcessMessages;
  end;

Nils_13 7. Sep 2005 16:04

Re: AlphaBlend für Delphi 5 Prof.
 
Nein, ahb ich auch schon probiert.

MarcoWarm 7. Sep 2005 16:04

Re: AlphaBlend für Delphi 5 Prof.
 
aber du musst das Fenster vorher wieder öffnen.... schließlich hast du es ja mit Form1.Close geschlossen

Nils_13 7. Sep 2005 16:09

Re: AlphaBlend für Delphi 5 Prof.
 
gut,

und weißt du noch, wie ich alles in eine Unit packe, sodass ich nur noch im Uses-Teil die Unit einbinden muss und dann nur noch
Delphi-Quellcode:
  MakeTransparent(Handle, 100);
sagen muss ?

[edit]Ich meine, ich habe ein Projekt und muss es nur noch einbidnen und aufrufen. [/edit]

Die bisherige Unit:
Delphi-Quellcode:
unit trans;

interface

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

implementation

type
    TSetLayeredWindowAttributes = function (
    hwnd : HWND; // handle to the layered window
    crKey : TColor;// specifies the color key
    bAlpha : byte;// value for the blend function
    dwFlags : DWORD// action
    ): BOOL; stdcall;

const
  WS_EX_LAYERED = $80000;
  LWA_COLORKEY = 1;
  LWA_ALPHA = 2;

procedure MakeTransparent(AHandle : THandle; AValue : byte = 0);
var
  Info: TOSVersionInfo;
  SetLayeredWindowAttributes: TSetLayeredWindowAttributes;
begin
//Check Windows version
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);
//Make form transparent
SetLayeredWindowAttributes(AHandle, 0, AValue, LWA_ALPHA);
end;
end;
end;

end.

MarcoWarm 7. Sep 2005 16:16

Re: AlphaBlend für Delphi 5 Prof.
 
also einfach die Prozedurendeklaration zwischen interface und implementation einfügen


Delphi-Quellcode:
unit TransparencyHelper;

interface

procedure MakeTransparent(AHandle: HWND; AValue: byte = 0);

implementation

procedure MakeTransparent(AHandle: HWND; AValue: byte = 0);
begin
  //und hier dein Code
end;
schöner wär's natürlich, wenn du ne eigene FormsKlasse von TForm ableitest... dann könntest du, ähnlich wie ab D6 die Alphablendwerte direkt per Property setzen.

Nils_13 7. Sep 2005 16:23

Re: AlphaBlend für Delphi 5 Prof.
 
thx, das läuft jetzt, aber das erscheinen läuft immer noch nciht.


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:51 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz