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

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个附件,已经成功下载630次)

最值得关注的外文源代码

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

einstein  2010年02月19日
做的不错
wdtx_txmy  2010年01月26日
相当不错了
yiyaogood  2009年12月04日
不错
collon  2009年11月12日
很好
dd  2009年09月20日
看样子不错
chen7020  2009年07月24日
效果很好,谢谢
Lena  2009年06月01日
看看,学习一下!
lsqcxqust  2009年06月01日
不错,谢谢
lw  2009年05月28日
不错不错
luoyangzk  2009年05月25日
谢谢,非常感谢
juzi87  2009年05月19日
wangjiancun  2009年05月14日
效果太好了
cxcfisher  2009年05月08日
学习一下
zclmoon  2009年05月01日
下下来看看。。谢谢先
hexuan8441  2009年04月14日
太好了,对我学习这很有帮助,谢谢
heheh  2009年03月26日
相当不错啊。。。。
lysank  2009年03月26日
下来用了
chgh76  2009年03月22日
很好很强大
wushli  2009年03月18日
支持一下。
tulip  2009年03月11日
非常棒
字数在300字内
请如实评论
CopyRight (C) codesoso.com 2007-2009 All Rights Reserved   免责声明
京ICP备08011023号