| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 626 人关注过本帖, 2 人收藏
标题:移动窗口
取消只看楼主 加入收藏
瓦药墙
Rank: 7Rank: 7Rank: 7
等 级:黑侠
帖 子:218
专家分:556
注 册:2009-9-16
结帖率:100%
收藏(2)
 问题点数:0 回复次数:0 
移动窗口
写着玩的




程序代码:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    HWND                    hWnd;
    RECT                    rect;
    int                     iScreenWidth, iScreenHeight;
    int                     iStepx, iStepy;
    int                     iSpeed;

    srand ( (unsigned) GetTickCount () );
    iSpeed = rand () % 4 + 1;

    printf ("我会移动, 你说怪不怪异?\n");
    iStepx = 1;
    iStepy = 1;

    iScreenWidth = GetSystemMetrics (SM_CXSCREEN);
    iScreenHeight = GetSystemMetrics (SM_CYSCREEN);
    hWnd = GetForegroundWindow ();
    SetWindowPos (hWnd, HWND_TOPMOST, 0, 0, 100, 100, SWP_NOSIZE);
    while (1)
    {
        GetWindowRect (hWnd, &rect);
        OffsetRect (&rect, iSpeed * iStepx, iSpeed * iStepy);
        if ( rect.right >= iScreenWidth || rect.left <= 0 )
        {
            iStepx *= -1;
        }
        if ( rect.bottom >= iScreenHeight || rect.top <= 0 )
        {
            iStepy *= -1;
        }
        MoveWindow (hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
        Sleep (10);
    }
    return 0;
}
2011-03-05 19:57
快速回复:移动窗口
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011807 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved