Цитата:
Сообщение от vers0
...Понедельник день тяжелый...
|
Полностью согласен с данным утверждением :-) вот рабочий пример выноса "тягомотины" на внешний обработчик с отслеживанием состояния флажка
Код:
type
TForm1 = class(TForm)
...
procedure WndProc(var Msg: TMessage); override;
procedure ExternalWndProc;
...
var
Form1: TForm1;
flg: bool;
...
procedure TForm1.ExternalWndProc;
var
p: TPoint;
i: integer;
begin
for i:=0 to 100 do
if flg then
begin
GetCursorPos(p);
SetCursorPos(p.X-5, p.Y+5);
Sleep(85);
Application.ProcessMessages;
GetCursorPos(p);
SetCursorPos(p.X+5, p.Y+5);
Sleep(85);
Application.ProcessMessages;
end
else exit;
end;
procedure TForm1.WndProc(var Msg: TMessage);
begin
inherited;
case Msg.Msg of
WM_LBUTTONDOWN:
begin
flg:= true;
ExternalWndProc;
end;
WM_LBUTTONUP: flg:= false;
end; {case}
end;