有没有象屏保那样的控件,能够使delphi开发的窗体动起来(200分)

  • 主题发起人 主题发起人 wecap
  • 开始时间 开始时间
W

wecap

Unregistered / Unconfirmed
GUEST, unregistred user!
有没有象屏保那样的控件,能够使delphi开发的窗体动起来
最好给出网址:或者例子
 
“屏保”和“窗体动起来”有什么关系?????
 
应该没有关系,
想效果好一些,用 OpenGL 或 DirectX 实现
 
我的意思是想当窗体关闭时,能够象屏保一样,使窗体回卷关闭,或者,从不同的角落慢慢消失
关闭,只是想使窗体达到这种效果
 
用AnimateWindow这个api可以实现
 
给你个控件,调用它的 FadeOut 就可以了:

unit TransparentSkin;

interface

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

type
TTransparentSkin = class(TComponent)
private
{ Private declarations }
FTransparency : ShortInt;
FFadeTime : ShortInt;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(Aowner : TComponent); override;
procedure SetTransparency(value : ShortInt);
procedure SetFadeTime(value : ShortInt);
{$IFDEF DELPHI3}
procedure SetTransparent(value : ShortInt);
{$ELSE}
procedure SetTransparent;overload;
procedure SetTransparent(value : ShortInt);overload;
{$ENDIF}
procedure SetTransparentWindowHandle(hWnd: LongInt; value : ShortInt);
procedure FadeOut;
procedure FadeInTo(value : ShortInt);
published
{ Published declarations }
property Transparency : ShortInt read FTransparency
write SetTransparency;
property FadeTime : ShortInt read FFadeTime
write SetFadeTime;

end;

procedure GetWindowsVersion(var Major : integer; var Minor : integer);
procedure Register;

implementation

const LWA_ALPHA = $2;
const GWL_EXSTYLE = (-20);
const WS_EX_LAYERED = $80000;
const WS_EX_TRANSPARENT = $20;

constructor TTransparentSkin.Create(Aowner : TComponent);
begin
inherited Create(Aowner);
FTransparency := 10;
FFadeTime := 5;
if not (csDesigning in ComponentState) then SetTransparent(FTransparency);
end;

procedure TTransparentSkin.SetTransparency(value : ShortInt);
begin
if FTransparency <> value then FTransparency := value;
end;

procedure TTransparentSkin.SetFadeTime(value : ShortInt);
begin
if FFadeTime <> value then FFadeTime := value;
end;

{$IFDEF DELPHI3}
procedure TTransparentSkin.SetTransparent(value : ShortInt);
begin
FTransparency := value;
SetTransparentWindowHandle((self.Owner as TForm).Handle, 100 - FTransparency);
end;
{$ELSE}
procedure TTransparentSkin.SetTransparent;
begin
SetTransparentWindowHandle((self.Owner as TForm).Handle, 100 - FTransparency);
end;

procedure TTransparentSkin.SetTransparent(value : ShortInt);
begin
FTransparency := value;
SetTransparentWindowHandle((self.Owner as TForm).Handle, 100 - FTransparency);
end;
{$ENDIF}

procedure TTransparentSkin.SetTransparentWindowHandle(hWnd: LongInt; value : ShortInt);
var
major, minor : integer;
old: longint;
User32: Cardinal;
SetLayeredWindowAttributes: function (hwnd: LongInt; crKey: byte; bAlpha: byte; dwFlags: LongInt): LongInt; stdcall;
begin
GetWindowsVersion(major, minor);
if ((major = 5) and (minor = 0)) then //Windows 2000(NT5)
begin
User32 := LoadLibrary('USER32');
if User32 <> 0 then
try
SetLayeredWindowAttributes := GetProcAddress(User32, 'SetLayeredWindowAttributes');
if @SetLayeredWindowAttributes <> nil then
begin
old := GetWindowLongA(hwnd,GWL_EXSTYLE);
SetWindowLongA(hwnd,GWL_EXSTYLE,old or WS_EX_LAYERED);
SetLayeredWindowAttributes(hwnd, 0, (255 * value) DIV 100, LWA_ALPHA);
end;
finally
FreeLibrary(User32);
end;
end;
end;

procedure TTransparentSkin.FadeOut;
var
iLoop : ShortInt;
begin
for iLoop := FTransparency to 100 do
begin
FTransparency := iLoop;
SetTransparentWindowHandle((self.Owner as TForm).Handle, 100 - FTransparency);
Sleep(FFadeTime);
end;

end;

procedure TTransparentSkin.FadeInTo(value : ShortInt);
var
iLoop : ShortInt;
begin
SetTransparent(100);
(self.Owner as TForm).Show;
for iLoop := 100 downto value do
begin
SetTransparentWindowHandle((self.Owner as TForm).Handle, 100 - iLoop);
(self.Owner as TForm).Refresh;
Sleep(FFadeTime);
end;
FTransparency := value;
end;

procedure GetWindowsVersion(var Major : integer;var Minor : integer);
var
l : longint;
begin
l := GetVersion;
Major := LoByte(LoWord(l));
Minor := HiByte(LoWord(l));
end;

procedure Register;
begin
RegisterComponents('Add On', [TTransparentSkin]);
end;

end.
 
beta大哥,我是新手,这个怎么注册哟,我搞不来com,再帮小弟一下,
 
beta 我注册了,可是好象只有一种功能哟,能不能显示不同的效果.我是直接在关闭窗体时加入的如下h.FadeOut;
h.FadeOut;
 
后退
顶部