|
|
[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]- // 飞入与伸展 - 从上往下
- //《Windows界面编程第十二篇 位图显示特效 飞入效果与伸展效果》
- //http://blog.csdn.net/morewindows/article/details/8696726
- void AnimateDraw_FlyingTopToBottom(HDC hdc, HDC hdcMem, int nWidth, int nHeight, UINT nIntervalTime = 2, BOOL bFade = TRUE)
- {
- int j;
- if (bFade)
- {
- for (j = 0; j <= nHeight; j++)
- {
- BitBlt(hdc, 0, 0, nWidth, j, hdcMem, 0, 0, SRCCOPY);
- Sleep(nIntervalTime);
- }
- }
- else
- {
- for (j = 0; j <= nHeight; j++)
- {
- BitBlt(hdc, 0, 0, nWidth, j, hdcMem, 0, nHeight - j, SRCCOPY);
- Sleep(nIntervalTime);
- }
- }
- BitBlt(hdc, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);
- }
- // 飞入与伸展 - 从下往上
- //《Windows界面编程第十二篇 位图显示特效 飞入效果与伸展效果》
- //http://blog.csdn.net/morewindows/article/details/8696726
- void AnimateDraw_FlyingBottomToTop(HDC hdc, HDC hdcMem, int nWidth, int nHeight, UINT nIntervalTime = 2, BOOL bFade = TRUE)
- {
- int j;
- if (bFade)
- {
- for (j = nHeight; j >= 0; j--)
- {
- BitBlt(hdc, 0, j, nWidth, nHeight - j, hdcMem, 0, j, SRCCOPY);
- Sleep(nIntervalTime);
- }
- }
- else
- {
- for (j = nHeight; j >= 0; j--)
- {
- BitBlt(hdc, 0, j, nWidth, nHeight - j, hdcMem, 0, 0, SRCCOPY);
- Sleep(nIntervalTime);
- }
- }
- BitBlt(hdc, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);
- }
- // 飞入与伸展 - 从左往右
- //《Windows界面编程第十二篇 位图显示特效 飞入效果与伸展效果》
- //http://blog.csdn.net/morewindows/article/details/8696726
- void AnimateDraw_FlyingLeftToRight(HDC hdc, HDC hdcMem, int nWidth, int nHeight, UINT nIntervalTime = 2, BOOL bFade = TRUE)
- {
- int i;
- if (bFade)
- {
- for (i = 0; i <= nWidth; i++)
- {
- BitBlt(hdc, 0, 0, i, nHeight, hdcMem, 0, 0, SRCCOPY);
- Sleep(nIntervalTime);
- }
- }
- else
- {
- for (i = 0; i <= nWidth; i++)
- {
- BitBlt(hdc, 0, 0, i, nHeight, hdcMem, nWidth - i, 0, SRCCOPY);
- Sleep(nIntervalTime);
- }
- }
- BitBlt(hdc, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);
- }
- // 飞入与伸展 - 从右往左
- //《Windows界面编程第十二篇 位图显示特效 飞入效果与伸展效果》
- //http://blog.csdn.net/morewindows/article/details/8696726
- void AnimateDraw_FlyingRightToLeft(HDC hdc, HDC hdcMem, int nWidth, int nHeight, UINT nIntervalTime = 2, BOOL bFade = TRUE)
- {
- int i;
- if (bFade)
- {
- for (i = nWidth; i >= 0; i--)
- {
- BitBlt(hdc, i, 0, nWidth - i, nHeight, hdcMem, i, 0, SRCCOPY);
- Sleep(nIntervalTime);
- }
- }
- else
- {
- for (i = nWidth; i >= 0; i--)
- {
- BitBlt(hdc, i, 0, nWidth - i, nHeight, hdcMem, 0, 0, SRCCOPY);
- Sleep(nIntervalTime);
- }
- }
- BitBlt(hdc, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);
- }
复制代码
[bgcolor=#ffffff]完整的程序在[/bgcolor][bgcolor=#ffffff]http://www.hifyl.com/read.php?tid=2763 [/bgcolor] |
|