您现在的位置:首页 >> 界面报表 >> 界面报表 >> 内容

Delphi制作类似QQ的闪屏震动效果

时间:2011/9/3 15:24:35 点击:

  核心提示:procedure LetWindowShake(wHandle: THandle) ;const MAXDELTA = 4; SHAKETIMES = 500;var orect, wRect :T...
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;

作者:网络 来源:转载
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
  • 盒子文章(www.2ccc.com) © 2024 版权所有 All Rights Reserved.
  • 沪ICP备05001939号