26. november 2002 - 14:54
#3
hvis ikke brug den her :
unit AlphaBlendForm;
interface
uses
Classes, Forms, Dialogs, Windows;
Type
TAlphaBlendForm = class(TForm)
private
FTransparency: Integer;
procedure SetTransparency(const Value: Integer);
public
constructor Create(AOwner : TComponent); override;
property Transparency : Integer read FTransparency write SetTransparency;
end;
implementation
Const
WS_EX_LAYERED = $00080000;
LWA_COLORKEY = $00000001;
LWA_ALPHA = $00000002;
ULW_COLORKEY = $00000001;
ULW_ALPHA = $00000002;
Type
PBlendFunction = ^TBlendFunction;
TBlendFunction = Packed Record
BlendOp : Byte;
BlendFlags : Byte;
SourceConstantAlpha : Byte;
AlphaFormat : Byte;
End;
Function SetLayeredWindowAttributes(hWnd : hWnd; crKey : TColorRef; bAlpha : Byte;
dwFlags : Integer) : Integer; StdCall;
External User32 Name 'SetLayeredWindowAttributes';
Function UpdateLayeredWindow(hWnd : hWnd; hdcDst : hDC; pptDst : PPoint; psize : PSize; hdcSrc : hDC;
pptSrc : PPoint; crKey : TColorRef; pblend : PBlendFunction;
dwFlags : Integer) : Integer; StdCall;
External User32 Name 'UpdateLayeredWindow';
{ TAlphaBlendForm }
constructor TAlphaBlendForm.Create(AOwner: TComponent);
begin
inherited;
SetWindowLong(Handle,GWL_EXSTYLE,GetWindowLong(Handle,GWL_EXSTYLE) Or WS_EX_LAYERED);
end;
procedure TAlphaBlendForm.SetTransparency(const Value: Integer);
begin
if FTransparency = Value then
exit;
FTransparency := Value;
SetLayeredWindowAttributes(Handle,0,FTransparency,LWA_ALPHA);
end;
end.