⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msgwndowner.cpp

📁 通信增值服务,上网接听电话
💻 CPP
字号:
// MsgWndOwner.cpp : implementation file
//

#include "stdafx.h"
#include "netpro.h"
#include "tapiutils.h"
#include "MsgWndOwner.h"
#include "NetproDLg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define MYCOLOR_BK RGB(47,87,144)
#define MYCOLOR_TEXT RGB(255,192,2)
/////////////////////////////////////////////////////////////////////////////
// CMsgWndOwner dialog


CMsgWndOwner::CMsgWndOwner(CWnd* pParent /*=NULL*/)
	: CDialog(CMsgWndOwner::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMsgWndOwner)
	m_sMsg1 = _T("");
	m_sPhonenum = _T("");
	//}}AFX_DATA_INIT
	m_sDialup = _T("");
	m_sMsg2 = _T("");
	m_bOnline = FALSE;
	m_iPos=0;

}


void CMsgWndOwner::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMsgWndOwner)
	DDX_Control(pDX, IDC_STATIC1, m_cStatic1);
	DDX_Control(pDX, IDC_STATIC_MSG1, m_cMsg1);
	DDX_Control(pDX, IDC_STATIC_MSG2, m_cMsg2);
	DDX_Control(pDX, IDC_STATIC_PHONENUM, m_cPhonenum);
	DDX_Text(pDX, IDC_STATIC_MSG1, m_sMsg1);
	DDX_Text(pDX, IDC_STATIC_PHONENUM, m_sPhonenum);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMsgWndOwner, CDialog)
	//{{AFX_MSG_MAP(CMsgWndOwner)
	//ON_WM_ERASEBKGND()
	ON_WM_CTLCOLOR()
	ON_WM_TIMER()
	ON_WM_CLOSE()
	ON_WM_NCDESTROY()
	ON_BN_CLICKED(IDC_STATIC_CTLOGO, OnStaticCtlogo)
	ON_WM_SETCURSOR()
	ON_BN_CLICKED(IDC_STATIC_PHONENUM, OnStaticPhonenum)
	//}}AFX_MSG_MAP
    ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMsgWndOwner message handlers

BOOL CMsgWndOwner::OnInitDialog() 
{
	CDialog::OnInitDialog();
	CString s;
	CNetproDlg* pDlg = (CNetproDlg*)GetParent()	;
	s = pDlg->GetAdURL();
	memset(m_strAdURL,0,sizeof(m_strAdURL));
	strcpy(m_strAdURL,(LPCTSTR)s);

	m_sMsg1.LoadString(IDS_WELCOME_USE_IPHONE);
	EnableToolTips();
    //m_BitmapBK.LoadBitmap(IDB_MSG_BK);
	//m_brush.CreateSolidBrush(RGB(132,138,221)); // color brush 
	m_brush.CreateSolidBrush(MYCOLOR_BK); // color white brush 

	memset(&m_logfont, 0, sizeof m_logfont);
	m_logfont.lfHeight = -14;
	lstrcpy(m_logfont.lfFaceName, _T("宋体"));
	m_logfont.lfOutPrecision = OUT_TT_PRECIS;
	m_logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
	m_logfont.lfQuality = PROOF_QUALITY;
	m_logfont.lfPitchAndFamily = FF_SWISS | VARIABLE_PITCH;
	m_logfont.lfWeight = FW_BOLD;
	CFont font,font2;
	if(font.CreateFontIndirect(&m_logfont)){
		m_cStatic1.SetFont(&font);
		m_cMsg1.SetFont(&font);
		m_cMsg2.SetFont(&font);
	}
	memcpy(&m_logfont2,&m_logfont,sizeof(LOGFONT));
	lstrcpy(m_logfont2.lfFaceName, _T("Arial"));
	if(font2.CreateFontIndirect(&m_logfont2)){
		m_cPhonenum.SetFont(&font2);
	}

	m_cMsg2.GetClientRect(m_Msg2Rect);

	m_pImageList = new CImageList();
	ASSERT(m_pImageList != NULL);    // serious allocation failure checking
	m_pImageList->Create(IDB_BITMAP_LED,16,6,RGB(255,0,255));

	CRect rect;
	m_cPhonenum.GetWindowRect(rect);
	m_LedPoint.x =rect.right+3;
	m_LedPoint.y =rect.top;

	ScreenToClient(&m_LedPoint);

	UpdateData(FALSE);
	StartTimer();
	/*
	VERIFY(m_cMsgwnd.SubclassDlgItem(IDC_STATIC_MSG, this));
	//m_cMsgwnd.m_PhoneNum = m_oDN;
	//m_cMsgwnd.m_cStatus2 = m_cStatus2;
	m_cMsgwnd.StartTimer();
	*/
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

BOOL CMsgWndOwner::SetMsgWndStatus(CString str, int nLine)
{
	switch(nLine)
	{
	case 0:
		m_sMsg1 = str;
		break;
	case 1:
		break;
	case 2:
		m_sMsg2 = str;
		break;
	case 3:
		m_sDialup = str;
		break;
	case 4:
		m_sPhonenum = str;
		break;
	default:
		;
	}
	
	PaintMsgWnd();
	return TRUE;
}

BOOL CMsgWndOwner::SetOnline(BOOL b)
{
	//m_cMsgwnd.m_bOnline = b;
	m_bOnline = b;
	return TRUE;
}

BOOL CMsgWndOwner::SetMsgWndStatus(UINT nID, int nLine)
{
	CString s;
	s.LoadString(nID);
	return SetMsgWndStatus(s,nLine);
}

void CMsgWndOwner::PaintMsgWnd()
{
	//m_cMsgwnd.PaintFlame();
	if(IsWindow(GetSafeHwnd())){
		UpdateData(FALSE);
		if(m_sMsg1.GetLength()>4){
			if(m_sMsg1.Left(4)=="接受"&&((m_iPos%40)<10?0:1)){
				m_cMsg1.SetWindowText("");
			}else{
			}
		}
		CDC* pDC = m_cMsg2.GetDC();
		pDC->SetTextColor(MYCOLOR_TEXT);
		pDC->SetBkColor(MYCOLOR_BK);
		//pDC->SetBkMode(TRANSPARENT);

		CString cValue;CSize size;
		cValue = m_sMsg2 + m_sDialup;
		int nLength = 0;
		if(cValue!=""){
			size = pDC->GetTextExtent(cValue);
		}else{
			size.cx=0;
			size.cy=0;
		}

		pDC->ExtTextOut(m_Msg2Rect.right-(int)m_iPos%(m_Msg2Rect.right+size.cx),0,ETO_OPAQUE|ETO_CLIPPED,m_Msg2Rect,(LPCTSTR)cValue,cValue.GetLength(),NULL);
		ReleaseDC(pDC);
		pDC = GetDC();
		m_pImageList->Draw(pDC,m_bOnline?3:((m_iPos%20)<10?0:1),m_LedPoint,ILD_TRANSPARENT);
		ReleaseDC(pDC);
	}

}

BOOL CMsgWndOwner::OnEraseBkgnd(CDC* pDC) 
{
	CDialog::OnEraseBkgnd(pDC);
	CRect	rect;
	GetWindowRect(&rect);

	CDC memDC;
	CBitmap*		pOldMemBmp = NULL;

	memDC.CreateCompatibleDC(pDC);
	pOldMemBmp = memDC.SelectObject(&m_BitmapBK);
	pDC->BitBlt(0, 0, rect.Width(), rect.Height(), &memDC, 0, 0, SRCCOPY);
	if (pOldMemBmp) 
		memDC.SelectObject( pOldMemBmp );	
	return TRUE;
}

HBRUSH CMsgWndOwner::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	
/*	pDC->SetBkMode(TRANSPARENT);

	return HBRUSH(m_br);
*/
   
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	LOGBRUSH logbrush;
	CBrush m_tmpBrush1;
	switch (nCtlColor)
	{
	//Edit controls need white background and black text
	//Note the 'return hbr' which is needed to draw the Edit
	//control's internal background (as opposed to text background)
	case CTLCOLOR_EDIT:
		m_brush.GetLogBrush( &logbrush );
		pDC->SetTextColor(MYCOLOR_TEXT);
		pDC->SetBkColor(logbrush.lbColor);
		return hbr;
	//Static controls need black text and same background as m_brush
	case CTLCOLOR_STATIC:
		m_brush.GetLogBrush( &logbrush );
		pDC->SetTextColor(MYCOLOR_TEXT);
		pDC->SetBkColor(logbrush.lbColor);
		return m_brush;
	//For listboxes, scrollbars, buttons, messageboxes and dialogs,
	//use the new brush (m_brush)
	
	case CTLCOLOR_BTN:

		m_brush.GetLogBrush( &logbrush );
		pDC->SetTextColor(RGB(255,255,0));
		pDC->SetBkColor(logbrush.lbColor);
		return m_brush;
	case CTLCOLOR_LISTBOX:
		m_brush.GetLogBrush( &logbrush );
		pDC->SetTextColor(RGB(255,255,0));
		pDC->SetBkColor(logbrush.lbColor);
		//m_tmpBrush1.CreateSolidBrush(RGB(0,255,0));
		return m_brush;
		
	case CTLCOLOR_SCROLLBAR:
	case CTLCOLOR_MSGBOX:
	case CTLCOLOR_DLG:
		return m_brush;
		break;
	//This shouldn't occurr since we took all the cases, but
	//JUST IN CASE, return the new brush
	default:
		return m_brush;
	}
	return hbr;
}


BOOL CMsgWndOwner::StartTimer()
{
	m_iTimer = SetTimer(201,100,NULL);
	if(m_iTimer)
		return TRUE;
	else
		return FALSE;

}

BOOL CMsgWndOwner::StopTimer()
{
	if(m_iTimer)
	{
		KillTimer(m_iTimer);
		m_iTimer = 0;
	//	m_iTimerCount = 0;
	}
	return TRUE;
}

void CMsgWndOwner::OnTimer(UINT nIDEvent) 
{
	if(m_iPos==60000)
		m_iPos=0;
	else
		m_iPos+=3;

	PaintMsgWnd();
	CDialog::OnTimer(nIDEvent);
}

void CMsgWndOwner::OnClose() 
{
	StopTimer();	
	
	CDialog::OnClose();
}

void CMsgWndOwner::OnNcDestroy() 
{
	CDialog::OnNcDestroy();
	if(m_pImageList)
		delete m_pImageList;
	
	
}


BOOL CMsgWndOwner::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
{
	switch(pWnd->GetDlgCtrlID()){
	case IDC_STATIC_CTLOGO:
	case IDC_STATIC_PHONENUM:
			SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_HAND));
		break;
	default:
		return CDialog::OnSetCursor(pWnd, nHitTest, message);
	}
	return TRUE;
}

BOOL CMsgWndOwner::OnToolTipNotify(UINT id, NMHDR * pNMHDR, LRESULT * pResult)
{
     
	TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
    UINT nID =pNMHDR->idFrom;
    if (pTTT->uFlags & TTF_IDISHWND)
    {
        // idFrom is actually the HWND of the tool
        nID = ::GetDlgCtrlID((HWND)nID);
        if(nID)
        {
			if(nID==IDC_STATIC_CTLOGO){
				pTTT->lpszText = m_strAdURL;
				pTTT->hinst = AfxGetResourceHandle();
				return(TRUE);

			}else{
				pTTT->lpszText = MAKEINTRESOURCE(nID);
				pTTT->hinst = AfxGetResourceHandle();
				return(TRUE);
			}
        }
    }
    return(FALSE);
}

void CMsgWndOwner::OnStaticPhonenum() 
{
	CNetproDlg* pDlg = (CNetproDlg*)GetParent()	;
	pDlg->PopupSetupDlg();	
}

void CMsgWndOwner::OnStaticCtlogo() 
{
	CNetproDlg* pDlg = (CNetproDlg*)GetParent()	;
	pDlg->GotoAdURL();
}

⌨️ 快捷键说明

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