// DialogMsg.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "DialogMsg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDialogMsg dialog


CDialogMsg::CDialogMsg(CWnd* pParent /*=NULL*/)
	: CDialog(CDialogMsg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDialogMsg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT

	m_color = RGB(255, 255, 255);
}


void CDialogMsg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDialogMsg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
		DDX_Text(pDX, IDC_MSG1, m_msg); 
		DDX_Control(pDX, IDC_MSG1, m_stMsg);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDialogMsg, CDialog)
	//{{AFX_MSG_MAP(CDialogMsg)
	ON_WM_CTLCOLOR()
	ON_WM_KEYDOWN()
	ON_WM_KEYUP()
	ON_WM_DRAWITEM()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDialogMsg message handlers

BOOL CDialogMsg::OnInitDialog() 
{
	m_stMsg.SubclassDlgItem(IDC_MSG1, this);

	m_brush.CreateSolidBrush(m_color); 
	m_stMsg.SetBkColor(m_color); 
	m_stMsg.SetTextColor(BLACK); 
	
	CDialog::OnInitDialog();	
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

HBRUSH CDialogMsg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	//HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	return m_brush;

	UNREFERENCED_PARAMETER(pDC);
	UNREFERENCED_PARAMETER(pWnd);
	UNREFERENCED_PARAMETER(nCtlColor);
	
	// TODO: Return a different brush if the default is not desired
	//return hbr;
}

void CDialogMsg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	
	//CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
	UNREFERENCED_PARAMETER(nChar);
	UNREFERENCED_PARAMETER(nRepCnt);
	UNREFERENCED_PARAMETER(nFlags);
}

void CDialogMsg::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	
	//CDialog::OnKeyUp(nChar, nRepCnt, nFlags);
	UNREFERENCED_PARAMETER(nChar);
	UNREFERENCED_PARAMETER(nRepCnt);
	UNREFERENCED_PARAMETER(nFlags);
}

BOOL CDialogMsg::PreTranslateMessage(MSG* pMsg) 
{
	if	 (pMsg->message == WM_KEYDOWN || 
		  pMsg->message == WM_KEYUP)
		  return FALSE;

	return CDialog::PreTranslateMessage(pMsg);
}

void CDialogMsg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	// TODO: Add your message handler code here and/or call default

	//if (lpDrawItemStruct->CtlID == IDC_MSG1)
	//	SetBkColor(lpDrawItemStruct->hDC, m_color);
	
	CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct);
}
