先把下面的代码保存成 TranForm.pas ;
component ->install component ->into newpackpage
unitfile name ://加上 TranForm.pas(包括文件的路径)
package filename ://自己定义包文件名
package description ://自己定义描述
->ok剩下的自己看着办吧!
//////////////
Unit TranForm; {DragonPC 2001.2.21}
Interface
Uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms ;
Type
TTranForm = class (TComponent)
Private
FAlphaValue: integer;
FParentFormHandle: HWND;
Procedure SetFAlphaValue (Alpha: integer);
Protected
Procedure UpdateDisplay;
Public
Constructor Create (AOwner: TComponent); override;
Published
Property AlphaValue: integer read FAlphaValue write SetFAlphaValue;
End;Const
WS_EX_LAYERED = $80000;
LWA_ALPHA = 2;Procedure Register;Function SetLayeredWindowAttributes (Handle: HWND; COLORKEY: COLORREF;
Alpha: BYTE; Flags: DWORD): Boolean; stdcall; external 'USER32.DLL';ImplementationProcedure Register;
Begin
RegisterComponents ('Standard', [TTranForm]);
End;Procedure TTranForm.SetFAlphaValue (Alpha: integer);
Begin
if (Alpha >= 0) and (Alpha < 256) then begin
FAlphaValue:= Alpha;
UpdateDisplay ();
End;
End;Procedure TTranForm.UpdateDisplay;
Begin
if (csDesigning in ComponentState) then Exit ;
SetLayeredWindowAttributes (FParentFormHandle, 0, FAlphaValue, 2);
End;Constructor TTranForm.Create (AOwner: TComponent);
Begin
Inherited;
if (csDesigning in ComponentState) then Exit;
FAlphaValue:= 255;
FParentFormHandle:= TForm (AOwner). Handle;
SetWindowLong (FParentFormHandle,
GWL_EXSTYLE, GetWindowLong (FParentFormHandle, GWL_EXSTYLE) or WS_EX_LAYERED);
End;End.
component ->install component ->into newpackpage
unitfile name ://加上 TranForm.pas(包括文件的路径)
package filename ://自己定义包文件名
package description ://自己定义描述
->ok剩下的自己看着办吧!
//////////////
Unit TranForm; {DragonPC 2001.2.21}
Interface
Uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms ;
Type
TTranForm = class (TComponent)
Private
FAlphaValue: integer;
FParentFormHandle: HWND;
Procedure SetFAlphaValue (Alpha: integer);
Protected
Procedure UpdateDisplay;
Public
Constructor Create (AOwner: TComponent); override;
Published
Property AlphaValue: integer read FAlphaValue write SetFAlphaValue;
End;Const
WS_EX_LAYERED = $80000;
LWA_ALPHA = 2;Procedure Register;Function SetLayeredWindowAttributes (Handle: HWND; COLORKEY: COLORREF;
Alpha: BYTE; Flags: DWORD): Boolean; stdcall; external 'USER32.DLL';ImplementationProcedure Register;
Begin
RegisterComponents ('Standard', [TTranForm]);
End;Procedure TTranForm.SetFAlphaValue (Alpha: integer);
Begin
if (Alpha >= 0) and (Alpha < 256) then begin
FAlphaValue:= Alpha;
UpdateDisplay ();
End;
End;Procedure TTranForm.UpdateDisplay;
Begin
if (csDesigning in ComponentState) then Exit ;
SetLayeredWindowAttributes (FParentFormHandle, 0, FAlphaValue, 2);
End;Constructor TTranForm.Create (AOwner: TComponent);
Begin
Inherited;
if (csDesigning in ComponentState) then Exit;
FAlphaValue:= 255;
FParentFormHandle:= TForm (AOwner). Handle;
SetWindowLong (FParentFormHandle,
GWL_EXSTYLE, GetWindowLong (FParentFormHandle, GWL_EXSTYLE) or WS_EX_LAYERED);
End;End.
调试也稍微麻烦一些。
看看帮助吧。
prodeure Registre;
begin
调用RegisterComponents;//注册面板
end;
再放到一个包里