c语言制做软件图标,c语言移动Windows桌面图标

移动windows桌面图标实现简单动画

这个操作需要关闭 桌面图标的自动排列

a5351977b9ee

image.png

#include

#include

#include

#include

#include

#define N 200

typedef struct node {

int x; // 横坐标

int y; // 纵坐标

int fx; // x 运动方向

int fy; // y 运动方向

}Node;

int main() {

int length, x = 60, y = 50, sum, i, weight = 1800, height = 850;

Node nodes[N];

HWND hwnd = FindWindow("Progman", NULL);

hwnd = GetWindow(hwnd, GW_CHILD);

hwnd = GetWindow(hwnd, GW_CHILD);

length = ListView_GetItemCount(hwnd);

length = length > N ? N : length;

for (i = 0; i < length; i++) {

nodes[i].x = x;

nodes[i].y = y;

nodes[i].fx = 1;

nodes[i].fy = 0;

SendMessage(hwnd, LVM_SETITEMPOSITION, i, MAKELPARAM(x, y));

}

while(!kbhit()){

for(sum = 1; sum < length; sum ++){

for(i = 0; i < sum; i++ ){

x = nodes[i].x + 60 * nodes[i].fx;

y = nodes[i].y + 50 * nodes[i].fy;

if(x > weight) {

nodes[i].fx = 0;

nodes[i].fy = 1;

if(y > height){

nodes[i].fx = -1;

nodes[i].fy = 0;

}

}

if(x <= 60) {

if(y >= height){

nodes[i].fy = -1;

nodes[i].fx = 0;

}

if(y <= 50){

nodes[i].fy = 0;

nodes[i].fx = 1;

}

}

nodes[i].x = x;

nodes[i].y = y;

}

for(i = 0; i < sum; i ++){

x = nodes[i].x;

y = nodes[i].y;

SendMessage(hwnd, LVM_SETITEMPOSITION, i, MAKELPARAM(x, y));

Sleep(2);

}

}

}

return 0;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值