hpmessagebox.cpp

来自「一个mapxmobile+gps的小程序,需要先安装mapx mobile」· C++ 代码 · 共 95 行

CPP
95
字号
// 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);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?