很容易,一个函数搞定:function SetLayeredWindowAttributes(hwnd:HWND; crKey:Longint; bAlpha:byte; dwFlags:longint ):longint; stdcall; external user32;//函数声明l:longint;
l:=getWindowLong(Handle, GWL_EXSTYLE);
    l := l Or WS_EX_LAYERED;
    SetWindowLong (handle, GWL_EXSTYLE, l);
    SetLayeredWindowAttributes (handle, 0, 200, LWA_ALPHA);
    //SetLayeredWindowAttributes (handle, RGB(255,255,255), 180, LWA_COLORKEY);
//第二个参数是指定透明颜色
//第二个参数为0则使用第四个参数设置alpha值,从0到255,其他的我不太清楚,因为没有api帮助试试吧!

解决方案 »

  1.   

    http://www.csdn.net/develop/read_article.asp?id=987
    http://www.csdn.net/develop/read_article.asp?id=306
      

  2.   

    给你一个组件:
    即使淡入淡出也很容易,一个循环就可以了。
    Dragon P.C. <[email protected]>
    http://www.webking.com.cnWindows 2000支持淡入淡出效果,大家都知道了。前两天研究FormContainer的Form显
    示效果时,得高人告知,核心API函数就是SetLayeredWindowAttributes,以下的控件
    代码是让你的窗口实现淡入淡出效果而设计,通过编程时动态改变AlphaValue值,您就
    可以看到效果了。unit TranForm;    {DragonPC 2001.2.21 }interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type
      TTranForm = class(TComponent)
      private
        FAlphaValue : integer ;
        FHandle : HWND ;
        procedure SetFAlphaValue(Alpha:integer) ;
      protected
        procedure UpdateDisplay ;
      public
        constructor Create(AOwner: TComponent); override;
      published
        property AlphaValue : integer read FAlphaValue write SetFAlphaValue ;
      end;procedure Register;function SetLayeredWindowAttributes
        (Handle : HWND; COLORKEY : COLORREF; Alpha : BYTE; Flags : DWORD) :
    Boolean;
        stdcall; external 'USER32.DLL';implementationprocedure Register;
    begin
      RegisterComponents('Standard', [TTranForm]);
    end;{ TTranForm }
    procedure TTranForm.SetFAlphaValue(Alpha: integer);
    begin
      if (Alpha >= 0) and (Alpha < 256) then begin
        FAlphaValue := Alpha ;
        UpdateDisplay() ;
      end else
        ShowMessage('请输入0~255之间的值!') ;
    end;procedure TTranForm.UpdateDisplay;
    begin
      if not (csDesigning in ComponentState) then
        SetLayeredWindowAttributes(FHandle, 0, FAlphaValue, 2);
      {我屏蔽了设计期的显示效果,如果你愿意可以改改,建议设计时最好不要看到效果}
    end;constructor TTranForm.Create(AOwner: TComponent);
    begin
      inherited;
      FAlphaValue := 255 ;
      FHandle := TForm(Owner).Handle ;
      if not (csDesigning in ComponentState) then
        SetWindowLong(FHandle,GWL_EXSTYLE, GetWindowLong(FHandle, GWL_EXSTYLE )
    or $80000 );
      {我屏蔽了设计期的显示效果,如果你愿意可以改改,建议设计时最好不要看到效果}
    end;end.