实现窗口从实变透明到消失这是一个例子

类别:Delphi 点击:0 评论:0 推荐:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) Timer1: TTimer; procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); private { Private declarations } public { Public declarations } end; Const WS_EX_LAYERED = $00080000; LMA_COLORKEY = $00000001; LMA_ALPHA = $00000002; var Form1: TForm1; Step: integer; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); var ExtStyle : LongInt; begin Step:=255; ExtStyle := GetWindowLong(Handle, GWL_EXSTYLE); SetWindowLong(Handle, GWL_EXSTYLE, ExtStyle or WS_EX_LAYERED); end; procedure TForm1.Timer1Timer(Sender: TObject); begin if Step>0 then begin Step:=Step-10; SetLayeredWindowAttributes(Handle, RGB(0,0,0), Step, LMA_ALPHA or LMA_COLORKEY); end else begin SetLayeredWindowAttributes(Handle, RGB(0,0,0), 255, 1); Timer1.Enabled:=False; end; end; end.

本文地址:http://com.8s8s.com/it/it4250.htm