home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 October
/
Chip_2001-10_cd1.bin
/
zkuste
/
delphi
/
kolekce
/
d56
/
TDSOFT.ZIP
/
TDTrasparentWindow.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2001-05-24
|
4KB
|
159 lines
{*******************************************************}
{ }
{ TDSoft Visual Component Library }
{ }
{ Copyright (c) 2001 Daniele Teti }
{ }
{-------------------------------------------------------}
{ For suggest, request, bug or only for sport: }
{ Daniele_Teti@hotmail.com }
{-------------------------------------------------------}
{ }
{ N.B Features available only in Windows 2000 }
{*******************************************************}
unit TDTrasparentWindow;
interface
uses
Dialogs,Windows, SysUtils, Classes, Forms,DsgnIntf;
{$R *.DCR}
type
TTDTrasparentWindow = class(TComponent)
private
FDelay: Cardinal;
procedure SetDelay(const Value: Cardinal);
function GetAbout: string;
procedure SetAbout(const Value: string);
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
function ShowTrasparent: LongBool; OverLoad;
function ShowTrasparent(Time: Cardinal): LongBool; OverLoad;
function HideTrasparent: LongBool; OverLoad;
function HideTrasparent(Time: Cardinal): LongBool; OverLoad;
published
{ Published declarations }
property Delay: Cardinal read FDelay write SetDelay;
property About: string read GetAbout write SetAbout stored False;
end;
TAboutProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure Edit; override;
end;
procedure Register;
implementation
type EParentIsNotAForm=class(Exception);
function TAboutProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
procedure TAboutProperty.Edit;
begin
MessageDlg('TTDTrasparentWindow 0.8b' + #13 + '(30/Dic/2000)' + #13 + #13 +
'written by Teti Daniele (Daniele_Teti@Hotmail.com)', mtInformation, [mbOk], 0);
end;
procedure Register;
begin
RegisterComponents('TDSoft', [TTDTrasparentWindow]);
RegisterPropertyEditor(TypeInfo(string), TTDTrasparentWindow, 'About', TAboutProperty);
end;
{ TTDTrasparentWindow }
function TTDTrasparentWindow.HideTrasparent: LongBool;
var
OwnerForm: TForm;
begin
Result:=False; //Solo x evitare gli WARNINGS 'HO GIA PROVATO CON LE DIRETTIVE AL COMPILATORE'!!!
if not(GetOwner is TForm) then
raise EParentIsNotAForm.Create('Owner component is not a TForm descendant');
try
OwnerForm:=TForm(GetOwner);
SetActiveWindow(OwnerForm.handle);
Result:=AnimateWindow(TForm(OwnerForm).handle,FDelay,AW_BLEND or AW_CENTER or AW_HIDE);
TForm(OwnerForm).Close;
except
if not(GetOwner is TForm) then
raise Exception.Create('InternalError.');
end;
end;
function TTDTrasparentWindow.GetAbout: string;
begin
Result:='TDSoft (c) Teti Daniele Component';
end;
function TTDTrasparentWindow.HideTrasparent(Time: Cardinal): LongBool;
begin
SetDelay(Time);
Result:=HideTrasparent;
end;
procedure TTDTrasparentWindow.SetDelay(const Value: Cardinal);
begin
FDelay := Value;
end;
function TTDTrasparentWindow.ShowTrasparent: LongBool;
var
OwnerForm: TForm;
begin
Result:=False; //Solo x evitare gli WARNINGS 'HO GIA PROVATO CON LE DIRETTIVE AL COMPILATORE'!!!
if not(GetOwner is TForm) then
raise EParentIsNotAForm.Create('Owner component is not a TForm descendant');
try
OwnerForm:=TForm(GetOwner);
SetActiveWindow(OwnerForm.handle);
Result:=AnimateWindow(TForm(OwnerForm).handle,FDelay,AW_BLEND or AW_CENTER or AW_ACTIVATE);
TForm(OwnerForm).Show;
TForm(OwnerForm).Invalidate;
except
if not(GetOwner is TForm) then
raise Exception.Create('InternalError.');
end;
end;
function TTDTrasparentWindow.ShowTrasparent(Time: Cardinal): LongBool;
begin
SetDelay(Time);
Result:=ShowTrasparent;
end;
procedure TTDTrasparentWindow.SetAbout(const Value: string);
begin
//Just for Syntax
end;
end.