31-01-2010, 05:06 PM
كود :
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Déclarations privées }
lar:Integer;
fpo:TRect;
H,Hand: THandle;
b:boolean;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Const
Pas=10;
procedure FindChildWindows(Ha: Integer);
var
h: THandle;
begin
h := GetWindow(Ha, GW_CHILD);
While h <> 0 do
Begin
InvalidateRect(H,nil,True);
FindChildWindows(h);
h := GetWindow(h, GW_HWNDNEXT);
End;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
po:TRect;
begin
// Application.ShowMainForm:=False;
H := FindWindow('Shell_TrayWnd', nil);
Hand := FindWindowEx(H, 0, 'Button', nil);
GetWindowRect(H,Po);
GetWindowRect(Hand,fPo);
fpo.Bottom:=fpo.Bottom-fpo.Top;
fpo.Top:=0;
fpo.Right:=fpo.Right-fpo.Left;
lar:=po.Right;
b:=False;
Timer1:=TTimer.Create(nil);
Timer1.Enabled:=False;
Timer1.OnTimer:=Timer1Timer;
Timer1.Interval:=100;
Timer1.Enabled:=true;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Timer1.Enabled:=False;
Timer1.Free;
MoveWindow(Hand,0,0,fpo.Right,fpo.Bottom,false);
InvalidateRect(H,nil,True);
FindChildWindows(h);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
n:integer;
begin
case b of
False:begin
n:=fpo.Left+pas;
if n+fpo.Right<lar then fpo.Left:=n
else b:=True;
end;
True:begin
if fpo.Left>pas then fpo.Left:=fpo.Left-pas
else b:=False;
end;
end;
MoveWindow(Hand,fpo.Left,fpo.Top,fpo.Right,fpo.Bottom,false);
InvalidateRect(H,nil,True);
FindChildWindows(h);
end;
end.
