当前注册人数422990人 邮箱: 密码: 注册新用户 忘记密码
首页 C/C++/MFC C# ASP.NET VB.NET MATLAB Android   站内搜索 下载代码说明/积分规则
为什么要注册?

1. 可以直接免费从本站下载代码,防止邮件发送不到您的邮箱,或登录不了国外网站

2. 可以设定关键字,当有您关心的代码收录时,邮件通知您

3. 对这里的代码进行评分和评论

4. 可以和大家一起分享你的源代码,得到更多的建议

Falling Snow on Your Desktop

VC++中的GDI实例教程:在屏幕上飘落的雪花源代码

2007年12月24日
Windows, VS (VS2005, VS6), VS
本文的程序实现在屏幕上随机产生不同大小的雪花,并以不同的速度下降。相对于第一版,它在很多性能上做了优化,直接在桌面的上下文中绘制雪花。而且,现在也通过RedrawWindow,实现在桌面的图标(如任务栏)上绘制雪花了。你可以用它来学习GDI。
相关知识
HDC hDC = GetDC(m_hWndDesktop);
 if(hDC)
 {
    RECT rc;
    rc.left = m_nCurrentX;
    rc.top = m_nCurrentY;
    rc.right = m_nCurrentX+15;
    rc.bottom = m_nCurrentY+15;

    // 15 is for a little drift at the bottom of the desktop
    int nTestHeight = m_nScreenHeight - 15; 
    
    // redraw the desktop window right away
    if(m_nCurrentY// snow drift here
        RedrawWindow(m_hWndDesktop, &rc, NULL, RDW_INVALIDATE 
            | RDW_ERASE | RDW_UPDATENOW );

     // ....

    m_nCurrentX += m_nIncrement;

    if(m_nCurrentY>m_nScreenHeight)
    {
        m_nCurrentY = 0;
        m_nCurrentX = abs(rand()*m_nScreenWidth/RAND_MAX);
        if(abs(rand()*100/RAND_MAX)>50)
            m_bIsBigFlake = TRUE;
        else
            m_bIsBigFlake = FALSE;
    }

   // ...

    HPEN pOldPen = (HPEN)SelectObject(hDC, m_hFlakePen);

   // ....

    // specify RDW_NOERASE to keep the desktop from drawing the background
    if(!m_bIsVista)
    {
        if(!m_bOverIcons && m_nCurrentY// Restore DC settings to their original values
    RestoreDC(hDC, storedDC);

    // Release the DC
    ReleaseDC(m_hWndDesktop, hDC);
 }
源代码原文下载:
Falling Snow on Your Desktop! Part II This article explains how to create an application that makes it snow on the desktop. Since my previous article was published, I received many user inquiries about how to improve the program. This article demonstrates how to create snow flakes that fall on your desktop, by using the draw functions directly in the desktop context. When the application starts, it creates an array of snow flakes and starts the timers for each flake. Manipulation of the RedrawWindow function allows the drawing of flakes behind and over the desktop icons, making the application more impressive.

源码图片

点击链接查看大图
从本站下载附件及源代码(1个附件,已经成功下载2156次)

最值得关注的外文源代码

Falling Snow on Your Desktop
Antialiasing Using Windows GDI
A Gauge Control Developed using GDI+
A .Net Tetris game in c# using GDI+
评论(评论是增加积分的一个有效途径)
字数在300字内
请如实评论
本源代码共评论279次,此处显示最近20次评论! 查看所有评论

hollito  2021年03月04日
谢谢楼主分享
huaiqishizu927  2018年07月16日
谢谢楼主分享
suiyue  2017年06月26日
我挺喜欢的! 感谢!
马叉虫  2016年10月25日
不错
Anyou2010  2016年01月26日
坑货,明明是C# 非得说是C++的.....
vnena  2015年05月29日
谢谢,很不错
xiangxiang  2015年05月24日
thanks for you sharing!
l747659997  2014年10月10日
不错啊
mengluo  2013年10月17日
perfect
hexing  2013年10月02日
好!!!!!!
杨小妞爱忘词  2013年09月16日
xiexie
lanyundetiankong  2013年06月12日
很好
evilsmile  2013年04月27日
有点意思
feifei  2013年04月24日
谢谢分享
伊唯涵  2013年04月21日
学习当中,希望这个例子能让我有大的提升
gao123456  2013年04月11日
看看啥东西
一诛仙一  2013年04月08日
很不错 学习了~~ 感谢大神!!!
豌豆先生  2013年03月30日
以前看到雪花漂很震撼的
幸运的狼  2013年03月12日
下了,还没看!希望不错!
kf200  2013年01月30日
好东西哦,来下载吧
字数在300字内
请如实评论
200万国内源码搜索
CopyRight (C) codesoso.com 2007-2009 All Rights Reserved zhihuishi   免责声明