找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 221|回复: 0

Windows界面编程第十二篇 位图显示特效 飞入效果与伸展效果

[复制链接]

52

主题

62

回帖

0

积分

版主

积分
0
发表于 2013-10-11 17:20:51 | 显示全部楼层 |阅读模式
[bgcolor=#ffffff]转载请标明出处,原文地址:[/bgcolor][bgcolor=#ffffff]http://blog.csdn.net/morewindows/article/details/8696726[/bgcolor]
本篇   
Windows界面编程第十二篇位图显示特效飞入效果与伸展效果
将讲解位图的飞入效果与伸展效果。飞入效果与伸展效果非常常见,在  
Windows界面编程第六篇动画启动效果(动画效果显示及隐藏窗口)
可以体验程序窗口在启动和退出的飞入动画效果与伸展动画效果。
从上往下的伸展效果
[p_w_upload=1155]



从下往上的伸展效果
[p_w_upload=1156]



从左往右的飞入效果
[p_w_upload=1157]

从右往左的飞入效果
[p_w_upload=1158]



[bgcolor=#ffffff]在程序设计上,只要计算好显示坐标就可以了,直接给出代码:[/bgcolor]
[bgcolor=#ffffff][/bgcolor]
  1. // 飞入与伸展 - 从上往下
  2. //《Windows界面编程第十二篇 位图显示特效 飞入效果与伸展效果》
  3. //http://blog.csdn.net/morewindows/article/details/8696726
  4. void AnimateDraw_FlyingTopToBottom(HDC hdc, HDC hdcMem, int nWidth, int nHeight, UINT nIntervalTime = 2, BOOL bFade = TRUE)
  5. {
  6.     int j;
  7.     if (bFade)
  8.     {
  9.         for (j = 0; j <= nHeight; j++)
  10.         {
  11.             BitBlt(hdc, 0, 0, nWidth, j, hdcMem, 0, 0, SRCCOPY);
  12.             Sleep(nIntervalTime);
  13.         }
  14.     }
  15.     else
  16.     {
  17.         for (j = 0; j <= nHeight; j++)
  18.         {
  19.             BitBlt(hdc, 0, 0, nWidth, j, hdcMem, 0, nHeight - j, SRCCOPY);
  20.             Sleep(nIntervalTime);
  21.         }
  22.     }
  23.     BitBlt(hdc, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);
  24. }
  25. // 飞入与伸展 - 从下往上
  26. //《Windows界面编程第十二篇 位图显示特效 飞入效果与伸展效果》
  27. //http://blog.csdn.net/morewindows/article/details/8696726
  28. void AnimateDraw_FlyingBottomToTop(HDC hdc, HDC hdcMem, int nWidth, int nHeight, UINT nIntervalTime = 2, BOOL bFade = TRUE)
  29. {
  30.     int j;
  31.     if (bFade)
  32.     {
  33.         for (j = nHeight; j >= 0; j--)
  34.         {
  35.             BitBlt(hdc, 0, j, nWidth, nHeight - j, hdcMem, 0, j, SRCCOPY);
  36.             Sleep(nIntervalTime);
  37.         }
  38.     }
  39.     else
  40.     {
  41.         for (j = nHeight; j >= 0; j--)
  42.         {
  43.             BitBlt(hdc, 0, j, nWidth, nHeight - j, hdcMem, 0, 0, SRCCOPY);
  44.             Sleep(nIntervalTime);
  45.         }
  46.     }
  47.     BitBlt(hdc, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);
  48. }
  49. // 飞入与伸展 - 从左往右
  50. //《Windows界面编程第十二篇 位图显示特效 飞入效果与伸展效果》
  51. //http://blog.csdn.net/morewindows/article/details/8696726
  52. void AnimateDraw_FlyingLeftToRight(HDC hdc, HDC hdcMem, int nWidth, int nHeight, UINT nIntervalTime = 2, BOOL bFade = TRUE)
  53. {
  54.     int i;
  55.     if (bFade)
  56.     {
  57.         for (i = 0; i <= nWidth; i++)
  58.         {
  59.             BitBlt(hdc, 0, 0, i, nHeight, hdcMem, 0, 0, SRCCOPY);
  60.             Sleep(nIntervalTime);
  61.         }
  62.     }
  63.     else
  64.     {
  65.         for (i = 0; i <= nWidth; i++)
  66.         {
  67.             BitBlt(hdc, 0, 0, i, nHeight, hdcMem, nWidth - i, 0, SRCCOPY);
  68.             Sleep(nIntervalTime);
  69.         }
  70.     }
  71.     BitBlt(hdc, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);
  72. }
  73. // 飞入与伸展 - 从右往左
  74. //《Windows界面编程第十二篇 位图显示特效 飞入效果与伸展效果》
  75. //http://blog.csdn.net/morewindows/article/details/8696726
  76. void AnimateDraw_FlyingRightToLeft(HDC hdc, HDC hdcMem, int nWidth, int nHeight, UINT nIntervalTime = 2, BOOL bFade = TRUE)
  77. {
  78.     int i;
  79.     if (bFade)
  80.     {
  81.         for (i = nWidth; i >= 0; i--)
  82.         {
  83.             BitBlt(hdc, i, 0, nWidth - i, nHeight, hdcMem, i, 0, SRCCOPY);
  84.             Sleep(nIntervalTime);
  85.         }
  86.     }
  87.     else
  88.     {
  89.         for (i = nWidth; i >= 0; i--)
  90.         {
  91.             BitBlt(hdc, i, 0, nWidth - i, nHeight, hdcMem, 0, 0, SRCCOPY);
  92.             Sleep(nIntervalTime);
  93.         }
  94.     }
  95.     BitBlt(hdc, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);
  96. }
复制代码


[bgcolor=#ffffff]完整的程序在[/bgcolor][bgcolor=#ffffff]http://www.hifyl.com/read.php?tid=2763 [/bgcolor]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

果子博客
扫码关注微信公众号

Archiver|手机版|小黑屋|风叶林

GMT+8, 2026-2-1 05:55 , Processed in 0.071701 second(s), 21 queries .

Powered by 风叶林

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表