#include<windows.h>
int WinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd )
{
RECT rect;//RECT定义了一个矩形结构体,存储矩形边框
HWND hwnd = NULL;//窗口句柄
int x, y, width, height;
int i;
for (int i = 0; i < 2; i++)
{
hwnd = (HWND)0x40256;//测试代码,可通过spy++查找一个测试窗口
if (IsWindow(hwnd))
{
GetWindowRect(hwnd, &rect);//获取指定窗口位置
x = rect.left;
y = rect.top;
width = rect.right - x;
height = rect.bottom - y;
}
else
return 0; //错误句柄
MoveWindow(hwnd, x - 5, y, width, height, TRUE);
Sleep(15);
MoveWindow(hwnd, x - 10, y, width, height, TRUE);
Sleep(15);
MoveWindow(hwnd, x - 10, y - 5, width, height, TRUE);
Sleep(15);
MoveWindow(hwnd, x - 10, y - 10, width, height, TRUE);
Sleep(15);
MoveWindow(hwnd, x - 5, y - 10, width, height, TRUE);
Sleep(15);
MoveWindow(hwnd, x, y - 10, width, height, TRUE);
Sleep(15);
MoveWindow(hwnd, x, y - 5, width, height, TRUE);
Sleep(15);
MoveWindow(hwnd, x, y, width, height, TRUE);
Sleep(15);
}
return 0;
}
窗口抖动效果实现
最新推荐文章于 2022-09-06 16:55:18 发布