www.pudn.com > HPMapx.rar > HPMessageBox.cpp


// HPMessageBox.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "HPMessageBox.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
CHPMessageBox::CHPMessageBox() 
{ 
	m_MessageHead = _T("ÏûÏ¢£º"); 
	m_MessageBody = _T("ÎÞ"); 
	bCurrentIsShow = true; 
} 
 
CHPMessageBox::~CHPMessageBox() 
{ 
} 
 
BEGIN_MESSAGE_MAP(CHPMessageBox, CGISSymble) 
	//{{AFX_MSG_MAP(CHPMessageBox) 
	ON_WM_TIMER() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
void CHPMessageBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)  
{ 
	CGISSymble::DrawItem(lpDrawItemStruct); 
	CDC dc; 
	dc.Attach(lpDrawItemStruct->hDC ); 
	dc.SetBkMode(TRANSPARENT); 
	dc.ExtTextOut(5,7,ETO_OPAQUE,NULL,m_MessageHead,m_MessageHead.GetLength(),NULL); 
	dc.ExtTextOut(40,7,ETO_OPAQUE,NULL,m_MessageBody,m_MessageBody.GetLength(),NULL); 
	dc.Detach(); 
} 
 
void CHPMessageBox::OnTimer(UINT nIDEvent)  
{ 
	switch(nIDEvent) 
	{ 
	case 1: 
		{ 
			static int n=TOP_START; 
			::MoveWindow(m_hWnd, 0, n-- , m_nWidth, m_nHeight, FALSE); 
			if( n == BOT_START ) 
			{ 
				KillTimer(1); 
				n=TOP_START; 
				bCurrentIsShow = true; 
			} 
			break; 
		} 
	case 2: 
		{ 
			static int n=BOT_START; 
			::MoveWindow( m_hWnd, 0, n++ , m_nWidth, m_nHeight, FALSE); 
			if( n == TOP_START ) 
			{ 
				KillTimer(2); 
				n=BOT_START; 
				bCurrentIsShow = false; 
			} 
			break; 
		} 
	case 3: 
		HideWindowEx(); 
		KillTimer(3); 
		bCurrentIsShow = false; 
		break; 
	} 
 
	CButton::OnTimer(nIDEvent); 
} 
 
void CHPMessageBox::ShowWindowEx() 
{ 
	if(bCurrentIsShow) 
		return; 
 
	SetTimer(1,NDELAY,NULL); 
	SetTimer(3,5000,NULL); 
} 
 
void CHPMessageBox::HideWindowEx() 
{ 
	if(!bCurrentIsShow) 
		return; 
	 
	SetTimer(2,NDELAY,NULL); 
}