WindowShake 함수를 수정하여 메신저 창 흔들기 따라하기.
void __fastcall ShakeWindow(HWND AHandle, int AMaxDelta = 4, int AShakeTimes = 500)
{
TRect rtDefault, rtCalc;
::GetWindowRect(AHandle, &rtDefault);
rtCalc = rtDefault;
srand(time(NULL));
for (int i = AShakeTimes; i-- > 0; )
{
rtCalc = rtDefault;
::OffsetRect(&rtCalc,
((int)RoundTo((rand() % 2), 0) << 1) - 1 * RoundTo(rand() % AMaxDelta, 0),
((int)RoundTo((rand() % 2), 0) << 1) - 1 * RoundTo(rand() % AMaxDelta, 0));
::MoveWindow(AHandle, rtCalc.Left, rtCalc.Top, rtCalc.Right - rtCalc.Left, rtCalc.Bottom - rtCalc.Top, true);
}
::MoveWindow(AHandle, rtDefault.Left, rtDefault.Top, rtDefault.Right - rtDefault.Left, rtDefault.Bottom - rtDefault.Top, true);
}
procedure ShakeWindow(AHandle: THandle; AMaxDelta: Integer = 4; AShakeTimes: Integer = 500);
var
rtDefault, rtCalc: TRect;
I: Integer;
begin
GetWindowRect(AHandle, rtDefault);
rtCalc := rtDefault;
Randomize;
for I := 0 to Pred(AShakeTimes) do
begin
rtCalc := rtDefault;
OffsetRect(rtCalc,
(Round(Random(2)) shl 1) - 1 * Round(Random(AMaxDelta)),
(Round(Random(2)) shl 1) - 1 * Round(Random(AMaxDelta)));
MoveWindow(AHandle, rtCalc.Left,rtCalc.Top,rtCalc.Right - rtCalc.Left,rtCalc.Bottom - rtCalc.Top, True);
end;
MoveWindow(AHandle, rtDefault.Left,rtDefault.Top,rtDefault.Right - rtDefault.Left,rtDefault.Bottom - rtDefault.Top, True);
end;