www.pudn.com > dialogic_IVR.rar > CHANSTATSMALLDIALOG.CPP


// ChanStatSmallDialog.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "PansrMTC.h" 
#include "ChanStatSmallDialog.h" 
 
#ifdef _DEBUG 
#if 0 
#define new DEBUG_NEW 
#endif 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
#define ACCESS_CODE_STR "Access Code: " 
 
///////////////////////////////////////////////////////////////////////////// 
// CChanStatSmallDialog dialog 
 
 
CChanStatSmallDialog::CChanStatSmallDialog(CWnd* pParent /*=NULL*/) 
{ 
	this->CChanStatSmallDialog::CChanStatSmallDialog(CChanStatSmallDialog::IDD, pParent); 
} 
 
 
CChanStatSmallDialog::CChanStatSmallDialog(UINT id, CWnd* pParent /*=NULL*/) 
	: CDialog(id, pParent) 
{ 
	m_green.CreateSolidBrush(RGB(0, 255, 0)); 
	m_red.CreateSolidBrush(RGB(255, 0, 0)); 
	//{{AFX_DATA_INIT(CChanStatSmallDialog) 
	m_chan_num_str = _T(""); 
	//}}AFX_DATA_INIT 
} 
 
 
BOOL CChanStatSmallDialog::Create 
	(int chanNum,  
  CWnd* pParent /*=NULL*/) 
{ 
	m_chan_num = chanNum; 
	m_chan_num_str.FormatMessage("%1!d!", m_chan_num); 
	m_color = &m_red; 
 
	return CDialog::Create(CChanStatSmallDialog::IDD, pParent); 
} 
 
 
BOOL CChanStatSmallDialog::Create 
	(UINT id, 
  int chanNum,  
  CWnd* pParent /*=NULL*/) 
{ 
	m_chan_num = chanNum; 
	m_chan_num_str.FormatMessage("%1!d!", m_chan_num); 
	m_color = &m_red; 
 
	return CDialog::Create(id, pParent); 
} 
 
 
 
void CChanStatSmallDialog::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CChanStatSmallDialog) 
	DDX_Control(pDX, IDC_BITMAP, m_bitmap); 
	DDX_Control(pDX, IDC_CHAN_COLOR, m_static_color); 
	DDX_Control(pDX, IDC_CHAN_NUM, m_static_chan_num); 
	DDX_Text(pDX, IDC_CHAN_NUM, m_chan_num_str); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CChanStatSmallDialog, CDialog) 
	//{{AFX_MSG_MAP(CChanStatSmallDialog) 
	ON_WM_PAINT() 
	//}}AFX_MSG_MAP 
  ON_MESSAGE(WM_DLGC_STATE, OnDialogicState) 
  ON_MESSAGE(WM_DLGC_CODE, OnDialogicCode) 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CChanStatSmallDialog message handlers 
 
 
LRESULT CChanStatSmallDialog::OnDialogicState 
  (WPARAM chanNum, 
  LPARAM state) 
{ 
	if (state == ST_ERROR) 
    { 
		if (m_color == &m_green) 
		{ 
			m_color = &m_red; 
			RedrawWindow(); 
		} 
    } 
	else 
    { 
		if (m_color == &m_red) 
		{ 
			m_color = &m_green; 
			RedrawWindow(); 
		} 
    } 
 
	switch (state) 
    { 
		case ST_OFFHOOK: 
		case ST_READY: 
			m_bitmap.SetBitmap(IDB_OFFHOOK); 
			break; 
 
		case ST_WTRING: 
		case ST_ONHOOK: 
			m_bitmap.SetBitmap(IDB_ONHOOK); 
			break; 
 
		default: 
		break; 
    } 
      
	return 0L;  
} 
 
 
LRESULT CChanStatSmallDialog::OnDialogicCode 
  (WPARAM chanNum, 
  LPARAM code) 
{ 
	return 0L;  
} 
 
 
void CChanStatSmallDialog::OnPaint()  
{ 
	CPaintDC dc(this); // device context for painting 
	RECT rect; 
	PAINTSTRUCT ps; 
	CDC *colorDC; 
 
	// because we only want to control this statics paint procedure 
	// and because it is simply, we do not bother creating an entirely 
	// new object inherited from CStatic.  Instead, by using BeginPaint 
	// and EndPaint, I assure the CStatic's default paint procedure will 
	// not be called. 
	colorDC = m_static_color.BeginPaint(&ps); 
	m_static_color.GetClientRect(&rect); 
	colorDC->FillRect(&rect, m_color);   
	m_static_color.EndPaint(&ps); 
} 
 
 
BOOL CChanStatSmallDialog::OnInitDialog()  
{ 
    CDialog::OnInitDialog(); 
	 
    m_bitmap.SetBitmap(0); // reset to clear 
 
    return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
}