// MsgLogDlg.cpp : implementation file
//

#include "stdafx.h"
#include "AG_MDA.h"
#include "MsgLogDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// MsgLogDlg dialog


MsgLogDlg::MsgLogDlg(CWnd* pParent /*=NULL*/)
	: CDialog(MsgLogDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(MsgLogDlg)
	m_Log = _T("");
	//}}AFX_DATA_INIT
}


void MsgLogDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(MsgLogDlg)
	DDX_Text(pDX, IDC_EDIT_LOG, m_Log);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(MsgLogDlg, CDialog)
	//{{AFX_MSG_MAP(MsgLogDlg)
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// MsgLogDlg message handlers

void MsgLogDlg::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	CEdit *edit = (CEdit*)GetDlgItem( IDC_EDIT_LOG );
	if( edit && ::IsWindow( edit->m_hWnd ) )
	{
		edit->SetWindowPos( NULL , 0 , 0 , cx ,cy , 0 );
	}
}

BOOL MsgLogDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CEdit *edit = (CEdit*)GetDlgItem( IDC_EDIT_LOG );
	edit->SetReadOnly( TRUE );
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void MsgLogDlg::AppendLog(CString str)
{
	CEdit *edit = (CEdit*)GetDlgItem( IDC_EDIT_LOG );
	COleDateTime tm;
	CString tmp;
	tm = COleDateTime::GetCurrentTime();
	tmp = tm.Format("%H:%M:%S   ");
	str += "\r\n";
	tmp += str;
	m_Log = tmp + m_Log;
	UpdateData( FALSE );
	edit->UpdateWindow();
}

void MsgLogDlg::ClearLog()
{
	m_Log ="";
	UpdateData( FALSE );
}
