Изменение положения нужного окна
Автор: Lookin
WEB-сайт: http://delphibase.endimus.com
{ **** UBPFD *********** by delphibase.endimus.com ****
>> Изменение положения нужного окна
Зависимости: Windows, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs,StdCtrls
Автор: lookin, lookin@mail.ru, Екатеринбург
Copyright: lookin
Дата: 06 мая 2002 г.
***************************************************** }
unit ShakeMe;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
procedure Shake(h: hWnd);
var
Form1: TForm1;
h, h1: hwnd;
p: array[0..255] of char;
no, ist: boolean;
s: string;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
a: string;
begin
a := Edit1.Text;
h := form1.handle;
no := false;
while no = false do
begin
ist := false;
h := GetNextWindow(h, GW_HWNDNEXT);
if h = 0 then
no := true;
GetWindowText(h, p, 255);
s := strpas(p);
if Pos(a, s) <> 0 then
Shake(h);
end;
no := false;
while no = false do
begin
ist := false;
h := GetNextWindow(h, GW_HWNDPREV);
if h = 0 then
no := true;
GetWindowText(h, p, 255);
s := strpas(p);
if Pos(a, s) <> 0 then
Shake(h);
end;
end;
procedure Shake(h: hWnd);
var
i: integer;
begin
//мертвый цикл
randomize;
i := 0;
while i = 0 do
begin
sleep(500);
SetWindowPos(h, 0, random(500), random(500), 0, 0, SWP_NOSIZE);
end;
end;
end.
|