用VC++制作MSN、QQ 的消息提示窗口(二)

2012-11-04 15:05:31 · 作者: · 浏览: 420
  二、QQ淡出淡出显示实现

  其实用到一个API函数:AnimateWindow,下面是这个函数的一些说明:

BOOL AnimateWindow(
 HWND hwnd, // handle to the window to animate
 DWORD dwTime, // duration of animation
 DWORD dwFlags // animation type
);

  上面的函数前两个参数一看就明白,不用说了,最后一个参数dwFlags设置动画窗口的样式:

  各种标志说明:

标志说明
AW_SLIDEUses slide animation. By default, roll animation is used.
This flag is ignored when used with the AW_CENTER flag.
AW_ACTIVATEActivates the window. Do not use this flag with AW_HIDE.
AW_BLENDUses a fade effect. This flag can be used only if hwnd is a top-level window.
AW_HIDEHides the window. By default, the window is shown.
AW_CENTERMakes the window appear to collapse inward if the AW_HIDE flag is used or expand outward
if the AW_HIDE flag is not used.
AW_HOR_POSITIVEAnimate the window from left to right. This flag can be used with roll or slide animation. It is ignored when used with the AW_CENTER flag.
AW_HOR_NEGATIVEAnimate the window from right to left. This flag can be used with roll or slide animation.
It is ignored when used with the AW_CENTER flag.
AW_VER_POSITIVEAnimate the window from top to bottom. This flag can be used with roll or slide animation.
It is ignored when used with the AW_CENTER flag.
AW_VER_NEGATIVEAnimate the window from bottom to top. This flag can be used with roll or slide animation.
It is ignored when used with the AW_CENTER flag.

  以上内容是从MSDN中摘录的,要淡入淡出的效果的话,用到AW_BELND。

  三、控制窗口显示的代码

CMainFrame::OnCreate(…)
{
 //...
 AnimateWindow(GetSafeHwnd(),1000,AW_CENTER|AW_BLEND);
 //…
}

  四、关闭的代码

CMainFrame::OnClose(..)
{
 AnimateWindow(GetSafeHwnd(),1000,AW_HIDE|AW_CENTER|AW_BLEND);
}

  其实AnimateWindow只是利用了windows本身的方法,如果您要更加有个性的窗口效果,那就得多做写些代码了,一分辛苦,一分收获吧

  五、结束语

  其实就MSN的提示窗口来说,如果要从使用复杂一点的背景和效果,那么还有刷新屏幕的问题,应做到无闪刷新.由于时间苍促,不足之处必然有之,同时以上代码也参考了一部分以前 VCKBASE 技术文档,在此表示感谢!

  如果有问题,欢迎交流!共同进步!