procedure LetWindowShake(wHandle: THandle) ;
const
   MAXDELTA = 4;
   SHAKETIMES = 500;
var
   orect, wRect :TRect;
   deltax : integer;
   deltay : integer;
   cnt : integer;
   dx, dy : integer;
begin
   //remember original position
   GetWindowRect(wHandle,wRect) ;
   orect := wRect;
   Randomize;
   for cnt := 0 to SHAKETIMES do
   begin
     deltax := Round(Random(MAXDELTA)) ;
     deltay := Round(Random(MAXDELTA)) ;
     dx := Round(1 + Random(2)) ;
     if dx = 2 then dx := -1;
     dy := Round(1 + Random(2)) ;
     if dy = 2 then dy := -1;
     OffsetRect(wRect,dx * deltax, dy * deltay) ;
     MoveWindow(wHandle, wRect.Left,wRect.Top,wRect.Right - wRect.Left,wRect.Bottom - wRect.Top,true) ;
   end;
   //return to start position
   MoveWindow(wHandle, orect.Left,oRect.Top,oRect.Right - orect.Left,oRect.Bottom - orect.Top,true) ;
end;

相关文章:

  • 2022-12-23
  • 2021-09-11
  • 2021-06-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
  • 2021-10-22
猜你喜欢
  • 2022-12-23
  • 2021-10-17
  • 2021-10-07
  • 2022-03-09
  • 2021-06-08
  • 2022-12-23
  • 2021-06-18
相关资源
相似解决方案