当前位置: 首页 > 图文教程 > 开发语言 > VC++ > 制作 MSN、QQ 的消息提示窗口
| 制作 MSN、QQ 的消息提示窗口 下载源代码 #define ID_TIMER_POP_WINDOW 1#define ID_TIMER_DISPALY_DELAY 2 #define ID_TIMER_CLOSE_WINDOW 3 从CWnd 继承一个窗口,当然也可以从CFrameWnd进行派生,这不是主要问题,关键是看你是怎么处理WM_PAINT,WM_MOUSEMOVE,WM_TIMER的消息。一般情况,我从OnPaint()中进行显示图片,在WM_TIMER中处理定时器消息,下面是处里定时器时用到的代码: CMsgWnd::CMsgWnd(){ ... SetTimer(ID_TIEMR_POP_WINDOW,20,NULL); ...} void CMsgWnd::OnTimer(UINT nIDEvent) { static int nHeight=0; int cy=GetSystemMetrics(SM_CYSCREEN); int cx=GetSystemMetrics(SM_CXSCREEN); RECT rect; SystemParametersInfo(SPI_GETWORKAREA,0,&rect,0); int y=rect.bottom-rect.top; int x=rect.right-rect.left; x=x-WIN_WIDTH; switch(nIDEvent) { case ID_TIMER_POP_WINDOW: if(nHeight<=WIN_HEIGHT) { ++nHeight; MoveWindow(x, y-nHeight, WIN_WIDTH, WIN_HEIGHT); Invalidate(FALSE); } else { KillTimer(ID_TIMER_POP_WINDOW); SetTimer(ID_TIMER_DISPLAY_DELAY,5000,NULL); } break; case ID_TIMER_CLOSE_WINDOW: if(nHeight>=0) { nHeight--; MoveWindow(x, y-nHeight, WIN_WIDTH, nHeight); } else { KillTimer(ID_TIMER_CLOSE_WINDOW); SendMessage(WM_CLOSE); } break; case ID_TIMER_DISPLAY_DELAY: KillTimer(ID_TIMER_DISPLAY_DELAY); SetTimer(ID_TIMER_CLOSE_WINDOW,20,NULL); break; } CWnd::OnTimer(nIDEvent);} 根据你设的定时器的长短来控制窗口的显示过程;二、QQ淡出淡出显示实现 其实用到一个API函数:AnimateWindow,下面是这个函数的一些说明: The AnimateWindow function enables you to produce special effects when showing or hiding windows.There are two types of animation: roll animation and slide animation. BOOL AnimateWindow( HWND hwnd, // handle to the window to animate DWORD dwTime, // duration of animation DWORD dwFlags // animation type );上面的函数前两个参数一看就明白,不用说了,最后一个参数dwFlags设置动画窗口的样式: Specifies the type of animation. This parameter can be one or more of the following flags. 各种标志说明:
|