TipDialog.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:4k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- // TipDialog.cpp : implementation file
- //
- #include "stdafx.h"
- #include "TipDialog.h"
- #include "mmsystem.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #pragma comment( lib , "winmm.lib" )
- /////////////////////////////////////////////////////////////////////////////
- // CTipDialog dialog
- bool CTipDialog::canShow = true;
- CTipDialog * CTipDialog::tipWnd = NULL;
- CBitmap CTipDialog::bmp;
- CTipDialog::CTipDialog(CWnd* pParent /*=NULL*/) : CDialog(CTipDialog::IDD, pParent )
- {
- //{{AFX_DATA_INIT(CTipDialog)
- //}}AFX_DATA_INIT
- this->text = "";
- this->up = true;
- this->delay = 0;
- if( ! CTipDialog::bmp.GetSafeHandle( ) )
- CTipDialog::bmp.LoadBitmap( IDB_SESSION_TIP_BITMAP );
- }
- void CTipDialog::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CTipDialog)
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CTipDialog, CDialog)
- //{{AFX_MSG_MAP(CTipDialog)
- ON_WM_PAINT()
- ON_WM_TIMER()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CTipDialog message handlers
- void CTipDialog::ShowTip( const char * tip , int delay )
- {
- if( ! CTipDialog::canShow )
- return;
- if( CTipDialog::IsWindow( ) )
- {
- CTipDialog::tipWnd->text += "n" + ( CString )tip;
- }
- else
- {
- CTipDialog::tipWnd = new CTipDialog( CWnd::GetDesktopWindow( ) );
- if( ! CTipDialog::tipWnd ) return;
- CTipDialog::tipWnd->text = tip;
- CTipDialog::tipWnd->delay = delay;
- CTipDialog::tipWnd->Create( CTipDialog::IDD );
- }
- }
- BOOL CTipDialog::OnInitDialog( )
- {
- CDialog::OnInitDialog();
- BITMAP bm;
- CTipDialog::bmp.GetBitmap( &bm );
- CRect rc( 0 , 0 , bm.bmWidth , bm.bmHeight );
- this->SetWindowPos( NULL , 0 , 0 , rc.Width( ) , rc.Height( ) , SWP_NOMOVE | SWP_NOACTIVATE );
- this->movePoint.x = ::GetSystemMetrics( SM_CXSCREEN ) - rc.Width( ) - 5;
- this->movePoint.y = ::GetSystemMetrics( SM_CYSCREEN ) - 5;
- this->tagetPoint.x = this->movePoint.x;
- this->tagetPoint.y = this->movePoint.y - rc.Height( );
- this->SetTimer( 1 , 10 , NULL );
- ::PlaySound( MAKEINTRESOURCE( IDR_TIP_WAVE ) , AfxGetResourceHandle() , SND_RESOURCE | SND_ASYNC );
- return TRUE;
- }
- void CTipDialog::OnPaint( )
- {
- CPaintDC dc( this );
- CDC memDC;
- memDC.CreateCompatibleDC( &dc );
- memDC.SelectObject( &CTipDialog::bmp );
- CRect rc , rcText;
- this->GetClientRect( &rc );
- dc.BitBlt( 0 , 0 , rc.Width( ) , rc.Height( ) , &memDC , 0 , 0 , SRCCOPY );
- rc.top += 25;
- rcText = rc;
- CFont f;
- f.CreatePointFont( 100 , "新宋体" );
- dc.SelectObject( &f );
- //计算矩形
- dc.DrawText( text , &rcText , DT_CALCRECT | DT_WORDBREAK );
- rcText.OffsetRect( ( rc.Width( ) - rcText.Width( ) ) / 2 , ( rc.Height( ) - rcText.Height( ) ) / 2 );
- dc.SetBkMode( TRANSPARENT );
- dc.SetTextColor( RGB( 0 , 0 , 255 ) );
- dc.DrawText( text , &rcText , DT_VCENTER | DT_CENTER | DT_WORDBREAK );
- }
- void CTipDialog::OnTimer( UINT nIDEvent )
- {
- CDialog::OnTimer( nIDEvent );
- if( nIDEvent == 1 )
- {
- if( this->up )
- {
- if( this->movePoint.y > this->tagetPoint.y )
- {
- this->SetWindowPos( NULL , this->movePoint.x , this->movePoint.y , 0 , 0 , SWP_NOSIZE | SWP_NOACTIVATE );
- this->movePoint.y -- ;
- }
- else
- {
- this->KillTimer( 1 );
- this->SetTimer( 2 , this->delay * 1000 , NULL );
- this->up = false;
- }
- }
- else
- {
- if( this->movePoint.y < ::GetSystemMetrics( SM_CYSCREEN ) - 5 )
- {
- this->SetWindowPos( NULL , this->movePoint.x , this->movePoint.y , 0 , 0 , SWP_NOSIZE | SWP_NOACTIVATE );
- this->movePoint.y ++ ;
- }
- else
- {
- CTipDialog::tipWnd = NULL;
- this->DestroyWindow( );
- }
- }
- }
- else if( nIDEvent == 2 )
- {
- this->KillTimer( 2 );
- this->SetTimer( 1 , 10 , NULL );
- }
- }
- LRESULT CTipDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
- {
- if( message == WM_CLOSE )
- {
- this->DestroyWindow( );
- return NULL;
- }
- else
- return CDialog::WindowProc(message, wParam, lParam);
- }
- void CTipDialog::PostNcDestroy( )
- {
- delete this;
- }